:checked JQ Home  <<  Selectors  <<  :checked

UI element states pseudo-class match selector.

Shorthand version $(':checked')


The :checked selector, selects all checked elements.

If this selector is not preceded by another selector, the universal selector ("*") is implied and so the whole DOM will be searched. Use another selector as in the example below to narrow the search and improve performance.

Selections apply to both checkboxes and radio buttons.


Signature Description
jQuery(':checked')UI element states pseudo-class match





:checked Example Selectors  <<  Top

Selects all checked elements.

The following example will check to see which checkboxes have been ticked and put out an appropriate message. Click on the boxes to see the output message change.

function pieCount() {
  var counter = $("form input:checked").length-1;
  $("#showcount").text("You like: " + (counter < 1 ? " none" : counter) 
                                    + " of our pies");


Please fill in our Pie Survey:

Pie Survey

 Click all pies that you like:

Related Tutorials

jQuery Basic Tutorials - Lesson 3 - CSS Selectors