Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Last active March 10, 2019 16:39
Show Gist options
  • Select an option

  • Save nathansmith/942659 to your computer and use it in GitHub Desktop.

Select an option

Save nathansmith/942659 to your computer and use it in GitHub Desktop.
Used to check all checkboxes in a page.
// Paste into Firebug or Chrome Dev Tools console
// when viewing a page with multiple checkboxes.
(function(d) {
var input = d.querySelectorAll('input[type="checkbox"]');
var i = input.length;
while (i--) {
input[i].checked = true;
}
})(this.document);
@kevinSuttle
Copy link
Copy Markdown

I can't get either one of these scripts to work in Firebug Lite or Chrome's Dev Console. I'm actually trying to do the opposite and uncheck all checkboxes on pages that don't have an check/uncheck all. i.e. Facebook's notification page. http://cl.ly/2R2U1m1w392n2S2K0z3S Any ideas?

@nathansmith
Copy link
Copy Markdown
Author

@kevinSuttle - This is what you need...

(function(d) {
  var input = d.querySelectorAll('input[type="checkbox"]');
  var i = input.length;

  while (i--) {
    input[i].checked = false;
  }    
})(this.document);

@kevinSuttle
Copy link
Copy Markdown

ROCK! Thanks Nathan!

@kevinSuttle
Copy link
Copy Markdown

Just used this on a shady recruiter. The first snippet works best.

@wellington1993
Copy link
Copy Markdown

Thanks! @nathansmith

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