开发者

Reading selected value of dropdown list in HTML by jQuery

开发者 https://www.devze.com 2023-02-12 16:35 出处:网络
I am trying to read the value of the selectedID in a drop down list in html through jQuery but it keeps producing an error. Did I miss something?

I am trying to read the value of the selectedID in a drop down list in html through jQuery but it keeps producing an error. Did I miss something?

<select style="width: 80px;" class="text ui-widget-content ui-corner-all" id="metaList">
<option value="4d5e3a8c4184开发者_如何学编程16ea16000000">Wikipedia</option>  
<option value="4d5e3a8c418416ea16010000">Twitter</option>  
<option value="4d5e3a8c418416ea16020000">DBPedia</option>  
<option value="4d64cd534184162629000000">test</option>          
</select>        

I tried which used to work before

var temp = $("#metaList").val(); 

but it produces NULL!


Your function call is correct, but nothing is selected. That is the reason why NULL is returned.


Try:

var temp = $("#metaList option:selected").val(); 
0

精彩评论

暂无评论...
验证码 换一张
取 消