Skip to content

Instantly share code, notes, and snippets.

@mahbubme
Created March 10, 2016 18:17
Show Gist options
  • Save mahbubme/762594a221e3e527c805 to your computer and use it in GitHub Desktop.
Save mahbubme/762594a221e3e527c805 to your computer and use it in GitHub Desktop.
Checked multiple checkbox at a time. ( jQuery dependency )
$(document).ready(function() {
$('#selectAllBoxes').click( function(event) {
if( this.checked ) {
$('.checkBoxes').each(function() {
this.checked = true;
});
}else {
$('.checkBoxes').each(function() {
this.checked = false;
});
}
});
});
@mahbubme
Copy link
Author

HTML code example

<input id="selectAllBoxes" type="checkbox">
<input class='checkBoxes' type='checkbox' name='checkBoxArray[]' value=' '>
<input class='checkBoxes' type='checkbox' name='checkBoxArray[]' value=' '>
<input class='checkBoxes' type='checkbox' name='checkBoxArray[]' value=' '>
<input class='checkBoxes' type='checkbox' name='checkBoxArray[]' value=' '>
<input class='checkBoxes' type='checkbox' name='checkBoxArray[]' value=' '>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment