[英]Jquery Selector not working in IE7
For the following HTML对于以下 HTML
<div id='parent'>
<input id='child' type=hidden value=''/>
</div>
I am doing我在做
$('#parent #child').val('test')
OR或者
$('#parent > #child').val('test')
but none of the above is working in IE7.但以上都不适用于IE7。 It does work in Firefox though
它确实在 Firefox 中工作
Any idea why is it not working?知道为什么它不起作用吗?
is it because you've got the HTML wrong?是因为你弄错了 HTML 吗? You should use " for attribute values. Sometimes IE is more sensitive to these things than Firefox
您应该使用 " 表示属性值。有时 IE 对这些东西比 Firefox 更敏感
Your syntax seems correct.您的语法似乎正确。 The only stuff I can think of that can muck this up are:
我能想到的唯一可以解决这个问题的是:
$(document).ready()
block$(document).ready()
块之间.prop()
instead of .attr()
if you're using jQuery 1.6+.prop()
而不是.attr()
Try $('#child').val('test');
试试
$('#child').val('test');
which would probably give the same result.这可能会给出相同的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.