JS获取select下拉框选中的value或者其name

Posted 有梦想的乌龟·

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS获取select下拉框选中的value或者其name相关的知识,希望对你有一定的参考价值。

举例:
<select class="js-example-basic-single js-states" style="width: 300px" name="hid" id="hid">
   
$("#hid option:checked").text()      //这是获取下拉框显示出来的值 【hid为select标签的id】
$("#hid option:checked").val()       //获取下拉框的value     
 
当然还有很多方式,就是jquery的选择器,在这里就介绍这一种。

以上是关于JS获取select下拉框选中的value或者其name的主要内容,如果未能解决你的问题,请参考以下文章