Group checkboxes in JSFiddle : Part 1
After solving Part 1 for Global Checkbox for All Check/Uncheck. I have couple other issues to solve.
- If I unchecked any of the items from list. Automatically Global (Check all) should be unchecked.
- If I checked all of items individually. Automatically Global (Check all) should be checked. like this.
Code
<fieldset>
<!-- these will be affected by check all -->
<div><input type="checkbox" ID="checkall1"> Check all</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
</fieldset>
<fieldset>
<!-- these won't be affected by check all; different field set -->
<div><input type="checkbox" ID="checkall2"> Check all</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
</fieldset>
JS
$('[id^=checkall]').click(function(){
$(this).closest('fieldset').find('input').not(this).prop('checked',this.checked);
});
Register a callback which will check whether all the checkboxes in the current group is checked or not
Demo: Fiddle