in chrome, no error, no warning and even no info.
it just not work.
$(document).ready(function () {
var cbxAdmins = $("input[name^=hasAdmin][type=checkbox]");
for (var i = 0; i < cbxAdmins.Length; i++) {
cbxAdmins[i].click(function () {
var checkAll = this.checked;
var permiCheckboxes = $(this).parents("tr:first").find(':checkbox');
if (checkAll) {
$(permiCheckboxes).attr('checked', true);
}
else {
$(permiCheckboxes).attr('checked', '');
}
});
}
});
You don’t need the
forloop across all the elements in the array, jQuery is smart enough to apply the click event individually. Try this:I’ve also cleaned up the logic a little, with thanks to Fabricio Matte.