<select >

     <option   value="1">jyy</option>  

     <option   value="2">abc</option>

</select>

code:

一:javascript方法

var  mySelect=document.getElementById("username");

var index=myselect.selectedIndex ;  

选中项的value:  myselect.options[index].value;

选中项的text:  myselect.options[index].text;

二:jquery方法(前提是已经加载了jquery库)

var options=$("#test option:selected"); 

选中项的value:alert(options.val());  

选中项的text:alert(options.text());  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-09-30
  • 2021-12-05
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2021-12-10
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-02-25
相关资源
相似解决方案