Reputation: 917
I'm using the following Jquery to check/uncheck checkboxes but some of the boxes in are disabled so I don't need to be checked.
Is there a way I can tell the script to ignore disabled checkboxes?
$('.uncheck').click(function () {
if ($(this).is(':checked')) {
$('.customers input:checkbox').removeAttr('checked');
} else {
$('.customers input:checkbox').attr('checked', 'checked');
}
});
Upvotes: 0
Views: 515
Reputation: 32581
Use not()
and :disabled
$('.customers input:checkbox').not(':disabled');
-
if ($(this).is(':checked')) {
$('.customers input:checkbox').not(':disabled').removeAttr('checked');
} else {
$('.customers input:checkbox').not(':disabled').attr('checked', 'checked');
}
Upvotes: 4