21 Dec 2009

The Easiest Way to Select All Checkboxes with jQuery

jQuery 1 Comment

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);

One Response to “The Easiest Way to Select All Checkboxes with jQuery”

  1. Yourbudweiser says:

    Nice, thanks!

Leave a Reply