[英]jQuery val() returns an array with IE8 on select/option element
The following alert returns "string" in the majors browsers. 以下警报在主要浏览器中返回“string”。 Returns "object" (an array of one element) on <=IE8.
返回<= IE8上的“object”(一个元素的数组)。
HTML: HTML:
<SELECT id="adults_1" type="select">
<OPTION value="1">1 persona</OPTION>
</SELECT>
JS: JS:
alert(typeof $("#adults_1").val());
JsFiddle: http://jsfiddle.net/JM9AY/2/ JsFiddle: http : //jsfiddle.net/JM9AY/2/
Is it a bug or it is the expected value? 它是一个错误还是预期值? If it's a bug, is there a workaround?
如果这是一个错误,是否有解决方法?
Removing type="select"
corrects this unexpected behavior. 删除
type="select"
更正此意外行为。 What is the meaning of the type
attribute here in any case? 这种
type
属性在任何情况下的含义是什么? There is no such attribute in HTML5. HTML5中没有这样的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.