Removing a checked property [closed]
In the jQuery documentation, it says
Do not use removeProp to remove native properties such as checked, disabled, or selected. This will remove the property completely and, once removed, cannot be added again to element. Use .prop() to set these properties to false instead.
Q: Instead of:
$('input:checkbox').not(this).removeAttr('checked');
I should I now us开发者_运维技巧e:
$('input:checkbox').not(this).prop('checked',false);
Use
$('input:checkbox').not(this).attr('checked', false);
See this example: http://jsfiddle.net/7586a/
Update: Seems like I didn't get the news about jQuery 1.6's .prop()
. Looks like your code is right.
精彩评论