Jquery Selector not working in IE7
For the following 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. It does work in Firefox though
Any idea why is it not working ?
is it because you've got the HTML wrong? You should use " for attribute values. Sometimes IE is more sensitive to these things than Firefox
Your syntax seems correct. The only stuff I can think of that can muck this up are:
- Make sure you've got your code between a
$(document).ready()
block - Maybe try
.prop()
instead of.attr()
if you're using jQuery 1.6+
Try $('#child').val('test');
which would probably give the same result.
精彩评论