js方法:
var myselect=document.getElementById(“test”);  //拿到select对象
var index=myselect.selectedIndex ; // selectedIndex代表的是你所选中项的index,拿到选中项的索引
myselect.options[index].value;  //拿到选中项options的value
myselect.options[index].text;  //拿到选中项options的text 
jQuery方法:
var options=$(“#test option:selected”); //获取选中的项
$(“#test option:selected”).val(); //拿到选中项的值
$(“#test option:selected”).text(); //拿到选中项的文本

  

posted on 2021-09-06 10:10  多年小白  阅读(130)  评论(0编辑  收藏  举报