jQuery :checked Selector

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is :checked?

: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)
NeedUse
Count ticked boxes$("input:checked").length
Checked checkboxes only$("input:checkbox:checked")
Selected radio value$("input[name=x]:checked").val()
Select options only$("option:selected")
Change checked state.prop("checked", true)

How to Use :checked

Select by live state, then count, read values, or validate — re-query after the user clicks.

  1. Prefix with a tag or type: $("input:checked") or $("input:checkbox:checked").
  2. Scope to a form when the page has many controls: $("#form input:checked").
  3. Read radio/checkbox values with .val() on the matched set.
  4. Re-run the selector on change or click so the result stays current.
  5. To toggle state, use .prop("checked", …) — not .attr("checked").
PieceRequired?Role
Selector stringYes:checked filter (best with a tag prefix)
Context / form idOptionalLimits the search to one form or container
Event handlerOptionalRefresh 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

Cheat Sheet

Keep these facts handy while working with form state.

TopicDetail
Syntax$("input:checked")
SincejQuery 1.0 · CSS standard
MatchesChecked checkboxes, radios, selected options
Live stateUses current property — not only the HTML attribute
vs :checkboxType filter (all boxes) vs state filter (ticked now)
vs :selectedUse :selected for select options only
Toggle.prop("checked", true|false)
Empty setNothing checked → length 0

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!

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);
Try It Yourself

How It Works

  1. Query. $("input:checked") finds every checked input right now.
  2. Count. .length is how many matched.
  3. Message. Singular/plural text is written to #count.
  4. Refresh. Each checkbox click runs countChecked again.

Example 2 — :checkbox vs :checked

Type filter vs state filter — combine them for checked checkboxes only.

jQuery
function update() {
  var lines = [
    "All checkboxes: " + $("input:checkbox").length,
    "Checked only: " + $("input:checkbox:checked").length
  ];
  $("#log").text(lines.join("\n"));
}

update();
$("input:checkbox").on("change", update);
Try It Yourself

How It Works

  1. Type. :checkbox matches every checkbox — checked or not.
  2. State. Adding :checked keeps only the ticked ones.
  3. Non-standard. :checkbox is a jQuery extension; :checked is CSS.
  4. Live. The change handler recalculates after each toggle.

Example 3 — Selected Radio Value

Official radio pattern: read the value of input:checked on click.

jQuery
$("input").on("click", function () {
  $("#log").text($("input:checked").val() + " is checked!");
});
Try It Yourself

How It Works

  1. Group. Radios share a name, so only one can be checked.
  2. Match. $("input:checked") finds that one radio.
  3. Value. .val() returns its value attribute.
  4. Safer. Prefer $("input[name=fruit]:checked") when other inputs exist.

Example 4 — Scoped Count in One Form

Limit the query so other forms on the page do not affect your count.

jQuery
function updateCount() {
  var n = $("#newsletterForm input:checkbox:checked").length;
  $("#scopedCount").text(n + " newsletter option(s) selected");
}

updateCount();
$("#newsletterForm input:checkbox").on("change", updateCount);
Try It Yourself

How It Works

  1. Scope. #newsletterForm limits the search to one form.
  2. Filter. input:checkbox:checked keeps ticked boxes only.
  3. Ignore. Checked boxes in #other never enter the count.
  4. 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.");
  }
});
Try It Yourself

How It Works

  1. Intercept. The submit handler runs before a real post.
  2. Test. :checked length 0 means nothing was accepted.
  3. Feedback. Show a clear message instead of a silent fail.
  4. Pass. When length ≥ 1, treat the form as valid for this rule.

Edge Cases & Pitfalls

Check these before shipping form logic that depends on :checked.

live

Attribute vs property

The HTML checked attribute is the initial state. After clicks, trust the live property — :checked and .prop("checked") see that.

scope

Bare $(":checked") is slow

It implies a universal scan. Prefer $("input:checked") or a form-scoped selector.

select

Options also match

:checked includes selected <option>s. For select-only work, use :selected.

non-std

:checkbox is a jQuery extension

:checked is standard CSS. :checkbox is not — equivalent to [type=checkbox] when you need native selectors.

Browser Support

The :checked pseudo-class is standard CSS and has been in jQuery since 1.0. It works wherever your jQuery build runs.

✓ Stable · CSS · jQuery 1.0+

jQuery :checked

Supported across jQuery 1.x, 2.x, and 3.x in every browser that runs your jQuery build. Prefer current jQuery 3.x for modern projects.

100% Form selector support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
:checked Universal

Bottom line: Safe everywhere jQuery runs. Prefer $("input:checked") (or a form-scoped query) for clarity and performance.

Performance Notes

ApproachCostBest for
$("input:checked")CheapTypical form pages
$("#form input:checked")CheapestMulti-form pages
$(":checked")SlowerAvoid — universal scan
$("input:checkbox:checked")CheapCheckboxes only (excludes radios)

Selector cost is rarely the bottleneck on small forms. Scope and a tag prefix matter more on large DOMs with many controls.

Key Takeaways

  • Role: match controls that are checked/selected right now.
  • Prefix: prefer $("input:checked") over bare $(":checked").
  • Toggle: change state with .prop("checked", …), find with :checked.
  • Selects: for options only, use :selected.

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.

Next: :selected Selector

Learn how to match selected <option> elements inside a <select>.

:selected tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful