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


复制代码 代码如下:

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

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3