Skip to content

Instantly share code, notes, and snippets.

@iamshanto
Created April 10, 2015 11:36
Show Gist options
  • Save iamshanto/0a6a761cb8026989f9dd to your computer and use it in GitHub Desktop.
Save iamshanto/0a6a761cb8026989f9dd to your computer and use it in GitHub Desktop.
<fieldset>
<!-- these will be affected by check all -->
<div><input type="checkbox" class="checkall"> 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"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
</fieldset>
<script>
$(function () {
$('.checkall').on('click', function () {
$(this).closest('fieldset').find(':checkbox').prop('checked', this.checked);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment