Javascript For Nested 'Select All' Checkboxes
I'm trying to display a list of checkboxes with a 'Select All' option for every item, and a 'Select All' item for each group. I have the following markup:
Solution 1:
Because you have both classes on that element
$(function () {
$('.checkall').on('click', function () {
$(this).closest('fieldset').find(':checkbox').prop('checked', this.checked);
});
$('.chkChild').on('click', function () {
if (!$(this).is('.checkall')) {
$(this).closest('fieldset').find('.checkall').prop('checked', false);
}
});
});
Demo: Fiddle
Post a Comment for "Javascript For Nested 'Select All' Checkboxes"