No mater if the radio button is checked or not, .is(‘:checked’) will return false. Here is some stuff I was playing with in Chrome’s console while I was debugging this:
> $('#blah')
[<input type="radio" id="blah" name="blah_type" value="blah" class="styled" checked="checked">]
> $('#blah').removeAttr('checked')
[<input type="radio" id="blah" name="blah_type" value="blah" class="styled">]
> $('#blah').is(':checked')
false
> $('#blah').prop('checked', true)
[<input type="radio" id="blah" name="blah_type" value="blah" class="styled">]
> $('#blah').is(':checked')
false
> $('#blah').prop('checked')
true
> $('#blah').removeProp('checked')
[<input type="radio" id="blah" name="blah_type" value="blah" class="styled">]
> $('#blah').attr('checked', true)
[<input type="radio" id="blah" name="blah_type" value="blah" class="styled" checked="checked">]
> $('#blah').attr('checked')
"checked"
> $('#blah').prop('checked')
undefined
> $('#blah').is(':checked')
false
What could be going wrong here? I’m using jQuery 1.6.4.
According to the jQuery API docs, do not use
.removeProp()to removecheckedor other native properties. I would assume the same for.removeAttr()as well.http://api.jquery.com/removeProp/