jQuery :checked Selector

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Checked state

What You’ll Learn

The :checked selector matches form elements that are currently checked or selected — ticked checkboxes, the active radio in a group, and chosen <option> elements. Available since jQuery 1.0; ideal for live counts, validation, and reading user choices.

01

Syntax

input:checked

02

Live

Current state

03

Checkbox

Ticked only

04

Official

countChecked

05

Radio

One selected

06

.prop

Set state

Introduction

Knowing which options a user picked is central to forms — newsletter preferences, payment methods, survey answers. The HTML checked attribute sets the initial state, but after clicks the live state lives in the DOM property — not the attribute alone.

jQuery’s :checked pseudo-class selects elements that are checked right now. It works on checkboxes, radio buttons, and selected options in <select> elements. Official docs note that for select-only queries you can also use :selected.

Understanding the :checked Selector

Think of :checked as a filter on top of form controls: “Is this box ticked or this option chosen at this moment?”

  • Checkbox ticked → matches input:checked.
  • Checkbox unticked → no match.
  • One radio selected in a group → only that radio matches.
  • Selected <option> → matches option:checked.
💡
Beginner Tip

To change checked state, use .prop("checked", true) — not .attr("checked"). Use :checked to find elements; use .prop() to toggle them.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( ":checked" )
// recommended — prefix with element type:
$( "input:checked" )
$( "input:checkbox:checked" )
$( "input[name='fruit']:checked" )

// read value of selected radio:
$( "input:checked" ).val()

Parameters

  • No arguments — filters by current checked/selected DOM state.

Return value

  • A jQuery object containing every checked or selected element in the search context.
  • Empty collection when nothing is checked.

Official jQuery API example

jQuery
var countChecked = function() {
  var n = $( "input:checked" ).length;
  $( "#count" ).text( n + ( n === 1 ? " is" : " are" ) + " checked!" );
};

countChecked();
$( "input[type=checkbox]" ).on( "click", countChecked );

⚡ Quick Reference

Control stateinput:checked
Checkbox tickedMatches
Checkbox untickedNo match
Selected radio in groupMatches (one only)
Unselected radiosNo match
checked attribute but user uncheckedNo match (live state wins)

📋 :checked vs :checkbox and :selected

State filter vs type filter — combine them for precise queries.

:checked
input:checked

Ticked/selected now

:checkbox
input:checkbox

All checkboxes

Combined
input:checkbox:checked

Checked boxes only

:selected
select option:selected

Select options

Examples Gallery

Example 1 follows the official jQuery countChecked demo. Examples 2–5 cover checkbox vs checked, radio value, scoped counting, and validation patterns. Use the Try-it links to run each snippet.

📚 Official jQuery Demo

Count checked inputs and update the message on every click.

Example 1 — Official Demo: countChecked()

Official jQuery demo — count input:checked elements and display “N are checked!”

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

Each click re-runs the counter. Only currently ticked inputs match :checked — unchecked boxes drop out of the count immediately.

Example 2 — input:checkbox vs input:checkbox:checked

Compare total checkboxes with how many are ticked.

jQuery
console.log( "All checkboxes:", $( "input:checkbox" ).length );
console.log( "Checked only:", $( "input:checkbox:checked" ).length );

// :checkbox = every box; :checked = ticked boxes only
Try It Yourself

How It Works

Stack pseudo-classes: :checkbox filters by type, :checked filters by state. Together they mean “ticked checkboxes only.”

📈 Practical Patterns

Radio selection, scoped counts, and form validation.

Example 3 — Read Selected Radio with input:checked (Official Example 2)

Display the value of whichever radio button is currently selected.

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

// Only one radio per name group matches :checked at a time
Try It Yourself

How It Works

Official jQuery example 2 uses input:checked to read the active radio’s value after each click.

Example 4 — Scoped Count $("#newsletterForm input:checked")

Count checked boxes inside one form without including radios elsewhere.

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

Scope with a form ID and combine :checkbox:checked so radio buttons in other fieldsets do not affect the count.

Example 5 — Require at Least One Checked Box

Block form submit when no checkbox in a group is ticked.

jQuery
$( "#termsForm" ).on( "submit", function( e ) {
  if ( $( "#termsForm input:checkbox:checked" ).length === 0 ) {
    e.preventDefault();
    alert( "Please accept at least one option." );
  }
});
Try It Yourself

How It Works

:checked gives you the live selection set. Testing .length === 0 is a simple validation gate before processing the form.

🚀 Common Use Cases

  • Live counter — show how many newsletter options are selected.
  • Radio display — show the chosen payment method label.
  • Validation — require at least one input:checkbox:checked.
  • Bulk actions — operate only on checked rows in a table.
  • Toggle styling — highlight labels next to checked inputs.
  • Serialize subset — collect values from checked inputs only.

🧠 How jQuery Evaluates :checked

1

Find candidates

Start from scoped inputs — preferably input:checked, not bare :checked.

Scope
2

Read property

Test the live checked property — not the static HTML attribute alone.

DOM
3

Filter selected

Keep checkboxes ticked, the active radio, and selected options.

State
4

Return collection

Matching elements become a jQuery object for chaining.

📝 Notes

  • Available since jQuery 1.0 — matches current checked/selected state.
  • Works on checkboxes, radios, and <option> elements.
  • For select-only queries, consider :selected per official docs.
  • Use .prop("checked") to read or set state — not .attr("checked").
  • Prefer input:checked over bare $(":checked") for clarity.
  • Re-query after user clicks — the matched set changes with each toggle.

Browser Support

The :checked pseudo-class is part of CSS3 and works in jQuery 1.0+. Evergreen browsers support input:checked in native querySelectorAll. jQuery evaluates live DOM state consistently across supported browsers.

CSS3 · jQuery 1.0+

jQuery :checked Selector

Supported in all modern browsers. Native: document.querySelectorAll("input:checked"). Reflects live checked property, not just initial HTML attribute.

100% Standard + jQuery
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: Use input:checkbox:checked for scoped queries. Pair with .prop() to toggle state, not .attr().

Conclusion

The :checked selector matches form elements that are checked or selected right now — not merely those with a checked attribute in the HTML source. The official countChecked() demo shows how to count ticked inputs and update the UI on every click.

Combine with :checkbox or :radio for precise queries, scope to a form ID, and use .prop("checked") when you need to change state rather than select elements.

💡 Best Practices

✅ Do

  • Use input:checkbox:checked for ticked boxes only
  • Re-run selectors after user toggles controls
  • Use .prop("checked") to set checked state
  • Scope counts to #formId input:checked
  • Read radio values with input:checked.val()

❌ Don’t

  • Rely on .attr("checked") for live state
  • Confuse :checkbox (all boxes) with :checked
  • Assume initial HTML checked never changes
  • Count bare $(":checked") across the whole document
  • Forget that only one radio per group matches at a time

Key Takeaways

Knowledge Unlocked

Five things to remember about :checked

Live checked and selected elements only.

5
Core concepts
cb 02

Checkbox

Ticked only

Use
radio 03

Radio

One match

Rule
.prop 04

Toggle

Not .attr

Tip
N 05

Official

countChecked

Demo

❓ Frequently Asked Questions

:checked matches every form element that is currently checked or selected — ticked checkboxes, the active radio button in a group, and selected option elements inside a select. It reflects live user state, not just the initial HTML checked attribute.
:checkbox matches all checkbox inputs regardless of state. :checked matches only those that are currently ticked. Use $("input:checkbox:checked") to select checked checkboxes only.
Yes. In a radio group, :checked matches the one radio input that is currently selected. $("input[name=fruit]:checked").val() returns the value of the chosen option.
Use :checked to select elements in the DOM (for styling, counting, or iterating). Use .prop("checked", true/false) to read or change the checked state on a specific element. Official jQuery docs recommend .prop over .attr for boolean form state.
:checked is standard CSS3 for checkboxes, radios, and options — but jQuery's bare $(":checked") is still a jQuery extension pattern. Prefer $("input:checked") or scoped selectors for clarity and performance.
:checked matches selected options in a select element. For select-only queries, jQuery also provides the :selected pseudo-class — use it when you want options without matching checkboxes or radios.
Did you know?

The HTML checked attribute sets the default state when the page loads, but it does not update when the user clicks. The :checked selector and .prop("checked") read the live property — which is what you want for interactive forms.

Continue to :selected Selector

Learn how to read selected option elements in dropdown menus — separate from :checked on checkboxes.

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

6 people found this page helpful