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?
checked and disabled are properties, as of jQuery 1.6 for modifying properties of the elements, prop method should be used instead of attr.
function enable_cb() {
$("input.group1")
.prop("disabled", this.checked)
.prop("checked", this.checked);
}
http://jsfiddle.net/JeqE5/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With