当前位置:首页 >> 网络编程

获取select元素被选中的文本内容的js代码

复制代码 代码如下:
var sel=document.getElementById(id);//select元素的id
var index=sel.selectedIndex;//获取被选中的option的索引
var textsel= sel.options[index].text;//获取相应的option的内容