nabeelfarid
nabeelfarid

Reputation: 4224

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 ?

Upvotes: 0

Views: 499

Answers (3)

Richard Neil Ilagan
Richard Neil Ilagan

Reputation: 14747

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+

Upvotes: 1

ianbarker
ianbarker

Reputation: 1254

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

Upvotes: 1

bhagyas
bhagyas

Reputation: 3080

Try $('#child').val('test'); which would probably give the same result.

Upvotes: 0

Related Questions