简体   繁体   English

使用jQuery获取选择框IE的价值。

[英]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 在IE(9)中返回undefined,但可在Chrome和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? 您能解释一下如何在IE和jQuery中获取选定的值吗?

Thank you! 谢谢!

First, here is a link, that shows you, that your posted code runs in IE 7-9 ( jsfiddle.net/FsfDD/ ). 首先,这是一个链接,向您显示您发布的代码在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 ). 也许您有与此类似的问题(jquery的.val()不适用于IE上的select元素 )。 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. 问题在于,当HTML中的ID属性设置为两个或多个元素时,这意味着ID不是唯一的,选择器在较旧的IE版本中不起作用。 ( eg jsfiddle.net/tvmY7/ ). (例如jsfiddle.net/tvmY7/)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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