Skip to content

Instantly share code, notes, and snippets.

@jerrylopez
Created May 19, 2014 19:38
Show Gist options
  • Select an option

  • Save jerrylopez/46d90a14335f25c6932a to your computer and use it in GitHub Desktop.

Select an option

Save jerrylopez/46d90a14335f25c6932a to your computer and use it in GitHub Desktop.
Check all checkboxes
/*
*
* Found at : http://jsfiddle.net/YxUHw/
*
* You can use this to check all check boxes just in case you have a crap load
* and there is no checkall button.
*
*/
(function () {
var checkboxes = document.querySelectorAll('input[type=checkbox]');
//convert nodelist to array
checkboxes = Array.prototype.slice.call(checkboxes);
checkboxes.forEach(function (checkbox) {
console.log(checkbox);
checkbox.setAttribute('checked', true);
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment