Created
February 20, 2014 09:31
-
-
Save djaoka/9110001 to your computer and use it in GitHub Desktop.
Select all checkboxes on a page - VanillaJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[].forEach.call(document.querySelectorAll(" input[type='checkbox']"), function(el) { el.checked = false; }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[].forEach.call(document.querySelectorAll(" input[type='checkbox']"), function(el) { el.click(); });
Setting the checkbox checked attribute will not always propagate all events that are triggered when a user selects a checkbox. Performing a click simulates user interaction.