21
Dec
2009
The Easiest Way to Select All Checkboxes with jQuery
After looking at many code samples online that were unnecessarily complex I’ve come up with my own simple method of selecting all checkboxes on a page:
$(":checkbox").attr("checked", true);
You can change the selector to target certain groups of checkboxes.
To deselect all checkboxes, simply change the “true” to “false”:
$(":checkbox").attr("checked", false);

Nice, thanks!