简体   繁体   中英

Get value of select box IE with jQuery.

var kontrakt = $("#kontrakt_select").find("option:selected").val(); 

returns undefined in IE(9) but works in Chrome and FireFox

<select id="kontrakt_select">
<option value="12345.1">19999.1 - 1992 ABC</option>
</select>

Can you explain how to get the selected value in IE iwth jQuery?

Thank you!

First, here is a link, that shows you, that your posted code runs in IE 7-9 ( jsfiddle.net/FsfDD/ ).

Maybe you have the same problem like in this post ( .val() of jquery not working for select element on IE ). There is the problem, that when an ID-Attribute in HTML is set to two or more elements, that means, the ID isn't unique, the selector doesn't work in older IE-Version. ( eg jsfiddle.net/tvmY7/ ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM