Skip to content

Instantly share code, notes, and snippets.

@djaoka
Created February 20, 2014 09:31
Show Gist options
  • Save djaoka/9110001 to your computer and use it in GitHub Desktop.
Save djaoka/9110001 to your computer and use it in GitHub Desktop.
Select all checkboxes on a page - VanillaJS
[].forEach.call(document.querySelectorAll(" input[type='checkbox']"), function(el) { el.checked = false; });
@Nilpo
Copy link

Nilpo commented Mar 10, 2022

[].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.

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