I have a jquery script that disables all checkboxes in a row and marks them as checked:
$(function() {
enable_cb();
$("#group1").click(enable_cb);
});
function enable_cb() {
if (this.checked) {
$("input.group1").attr("disabled", true);
$("input.group1").attr("checked", true);
} else {
$("input.group1").removeAttr("disabled","checked");
}
}
Here is my fiddle with the html: http://jsfiddle.net/3fksv/16/
I want the rest of the checkboxes to show active again, and unchecked on uncheck of the checkbox. What am I doing wrong in my script?
I don’t think that you can remove two attributes at once like that. You might have to use two calls to the
removeAttr()function –As @nickf correctly mentioned, these commands can also be chained –