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);
  • Share/Bookmark

You can follow any responses to this entry through the RSS 2.0 feed.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>