1. 程式人生 > >JS獲取select下拉框選中的value或者其name

JS獲取select下拉框選中的value或者其name

text single nbsp -s 舉例 sta c-s jquer hid

舉例: <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