Skip to content

Instantly share code, notes, and snippets.

@filipebarcos
Created October 29, 2012 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipebarcos/3974597 to your computer and use it in GitHub Desktop.
Save filipebarcos/3974597 to your computer and use it in GitHub Desktop.
Check all checkboxes in a form
$.each($('input:checkbox'), function(key, elem) {
$(elem).attr('checked', 'checked');
});
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == 'checkbox') {
inputs[i].checked = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment