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
Fundamentals
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.
Concept
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.
Foundation
📝 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 );
Cheat Sheet
⚡ Quick Reference
Control state
input:checked
Checkbox ticked
Matches
Checkbox unticked
No match
Selected radio in group
Matches (one only)
Unselected radios
No match
checked attribute but user unchecked
No match (live state wins)
Compare
📋 :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
Hands-On
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 );
All checkboxes: 5
Checked only: 2
Combine type + state pseudo-classes for precise queries
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
No boxes checked → alert, submit blocked
At least one checked → form submits
How It Works
:checked gives you the live selection set. Testing .length === 0 is a simple validation gate before processing the form.
Applications
🚀 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.
Important
📝 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.
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
:checkedUniversal
Bottom line: Use input:checkbox:checked for scoped queries. Pair with .prop() to toggle state, not .attr().
Wrap Up
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.
Count bare $(":checked") across the whole document
Forget that only one radio per group matches at a time
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :checked
Live checked and selected elements only.
5
Core concepts
✓01
:checked
Live state
API
cb02
Checkbox
Ticked only
Use
radio03
Radio
One match
Rule
.prop04
Toggle
Not .attr
Tip
N05
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.