The Easiest Way to Select All Checkboxes with jQuery
Posted by chad on December 21st, 2009 | 0 comments
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);