Reputation: 705
I have the following code
<input type="radio" name="HotelSearch_Measure" value="Miles">
<input type="radio" name="HotelSearch_Measure" value="KM">
However when I use the following it works in IE9/Chrome/Firefox but not in IE6
jQuery("input[value='Miles'").attr("checked", true);
I've tried searching with no luck.
Thanks in advance.
Upvotes: 0
Views: 989
Reputation: 20415
jQuery 1.6+ uses prop() like this:
jQuery('input[value="Miles"]').prop("checked", true);
Upvotes: 0
Reputation: 75317
Provided your typo (jQuery("input[value='Miles']").attr("checked", true);
) occurred when typing your question, and isn't present in your live code, what you have is the correct way to do it, prior to jQuery 1.6.0.
With the new version however, the new method prop()
should be used:
jQuery("input[value='Miles']").prop("checked", true);
Upvotes: 0
Reputation: 146310
If you are using jQuery < 1.6
do this:
jQuery("input[value='Miles']").attr("checked", 'checked');
If you are using jQuery 1.6+:
jQuery("input[value='Miles']").prop("checked", true);
See this question: .prop() vs .attr() and Possible bug in jQuery 1.6 - $(...).attr("checked") is not working for references why.
Upvotes: 1
Reputation: 4707
I believe this will work for IE6 and for the other browsers also
jQuery("input[value='Miles']").attr("checked", "checked");
Upvotes: 2