:checkedS2C Home « Selectors « :checked

UI element states pseudo-class match selector.

Shorthand version  $(':checked')

Description

The :checked selector, selects all checked elements.

Syntax


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

Parameters

None.

Return

N/A.

:checked Examplego to top of page 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;
  $("#showcount").text("You like: " + (counter < 1 ? " none" : counter) 
                                    + " of our pies");
}
pieCount();
$(":checkbox").click(pieCount); 

Please fill in our Pie Survey:

Pie Survey

 Click all pies that you like:



go to home page Homepage go to top of page Top