jQuery :checked Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

: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.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("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)
CallWhat it does
Selector string:checked filter (best with a tag prefix)
Context / form idLimits the search to one form or container
Event handlerRefresh counts/values after user interaction
Return valuejQuery collection of matching elements (may be empty)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Prefix with a tag or type: $("input:checked") or $("input:checkbox:checked").
Step 2Scope to a form when the page has many controls: $("#form input:checked").
Step 3Read radio/checkbox values with .val() on the matched set.

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.

jQuery Examples

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.

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.

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.

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 — Selected Options

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

:selected Selector — Selected Options tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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