:checked (since jQuery 1.0) matches elements that are checked or selected right now — ticked checkboxes, the active radio in a group, and selected <option> elements. It is a standard CSS pseudo-class that jQuery supports in $() queries.
Remember
$("input:checked") // checked inputs now
$("input:checkbox:checked") // ticked checkboxes only
$("input[name=fruit]:checked") // selected radio in a group
$("option:checked") // selected options
// For select-only queries, prefer :selected
// Toggle state with .prop("checked", true/false)
Select by live state, then count, read values, or validate — re-query after the user clicks.
Prefix with a tag or type: $("input:checked") or $("input:checkbox:checked").
Scope to a form when the page has many controls: $("#form input:checked").
Read radio/checkbox values with .val() on the matched set.
Re-run the selector on change or click so the result stays current.
To toggle state, use .prop("checked", …) — not .attr("checked").
Piece
Required?
Role
Selector string
Yes
:checked filter (best with a tag prefix)
Context / form id
Optional
Limits the search to one form or container
Event handler
Optional
Refresh counts/values after user interaction
Return value
—
jQuery collection of matching elements (may be empty)
Pseudocode
Pseudocode
matches = []
for each element in search context:
if element is checkbox/radio/option
and element is currently checked/selected:
matches.add(element)
return matches
// Common follow-ups:
count = matches.length
value = first(matches).value // radios / single checkbox
Reference
Cheat Sheet
Keep these facts handy while working with form state.
Topic
Detail
Syntax
$("input:checked")
Since
jQuery 1.0 · CSS standard
Matches
Checked checkboxes, radios, selected options
Live state
Uses current property — not only the HTML attribute
vs :checkbox
Type filter (all boxes) vs state filter (ticked now)
vs :selected
Use :selected for select options only
Toggle
.prop("checked", true|false)
Empty set
Nothing checked → length 0
Try it
Live Preview
Toggle the boxes, then run $("input:checked").length against this mini form.
Newsletter options
Same idea as the official jQuery countChecked demo — live DOM state only.
Result
$("input:checked").length
→ 2
2 are checked!
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Count Checked Inputs
Official idea: count input:checked and update the message on click.
jQuery
var countChecked = function () {
var n = $("input:checked").length;
$("#count").text(n + (n === 1 ? " is" : " are") + " checked!");
};
countChecked();
$("input[type=checkbox]").on("click", countChecked);
Ignore. Checked boxes in #other never enter the count.
Update. Listen on that form’s checkboxes only.
Example 5 — Require at Least One Checked
Simple validation: block submit when no checkbox is ticked.
jQuery
$("#termsForm").on("submit", function (e) {
e.preventDefault();
if ($("#termsForm input:checkbox:checked").length === 0) {
$("#msg").text("Please accept at least one option.");
} else {
$("#msg").text("Form OK — ready to send.");
}
});
One line::checked finds live checked/selected form state — prefix with input, scope to a form, and toggle with .prop().
Frequently Asked Questions
:checked matches form controls that are currently checked or selected — ticked checkboxes, the active radio in a group, and selected option elements. It reflects live DOM state, not only the initial HTML checked attribute.
:checkbox matches every checkbox input regardless of state. :checked matches only controls that are checked/selected right now. Use $("input:checkbox:checked") for checked checkboxes only. Note: :checkbox is a jQuery extension; :checked is standard CSS.
Yes. In a radio group, :checked matches the one radio that is selected. $("input[name=fruit]:checked").val() returns that option’s value.
Use :checked to find matching elements (count, style, iterate). Use .prop("checked", true/false) to read or change the checked state on a specific element. Prefer .prop over .attr for boolean form state.
Yes. :checked is a CSS pseudo-class (Selectors Level 3 / HTML). jQuery supports it since 1.0. Prefer $("input:checked") over bare $(":checked") so the query does not scan every element.
:checked matches selected options inside a select. For select-only queries, jQuery also provides :selected — use it when you want options without matching checkboxes or radios.