jQuery \"Check All\"


/ Published in: JavaScript
Save to your folder(s)

How does it work?

This code checks/unchecks all checkboxes within the same fieldset. Simple and semantic.
HTML Setup

Add checkboxes however you like, just make sure they are within the same fieldset.



Check all
Checkbox
Checkbox
Checkbox



Checkbox
Checkbox
Checkbox


Copy this code and paste it in your HTML
  1. $(function () {
  2. $('.checkall').click(function () {
  3. $(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
  4. });
  5. });

URL: http://briancray.com/posts/check-all-jquery-javascript

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.