The :checkbox selector matches every input element with type="checkbox". It is a jQuery form pseudo-class (since 1.0) — ideal for styling groups, counting selections, and wiring check-all behavior in forms.
01
Syntax
input:checkbox
02
type
= checkbox
03
Prefix
Use input
04
Official
.wrap demo
05
vs :radio
Separate types
06
CSS alt
[type=checkbox]
Fundamentals
Introduction
Checkbox inputs let users toggle options on and off — newsletter signup, terms acceptance, multi-select lists. When a form has several checkboxes, you often need to select them all at once for styling, validation, or a master “check all” control.
jQuery’s :checkbox pseudo-class targets every <input type="checkbox"> in your search context. It has existed since jQuery 1.0 and is equivalent to $("[type=checkbox]"). Official docs recommend writing input:checkbox rather than bare :checkbox.
Concept
Understanding the :checkbox Selector
Think of :checkbox as a shortcut for “every checkbox input in this scope.” It filters by the HTML type attribute — nothing else.
<input type="checkbox"> → matches.
<input type="radio"> → no match (use :radio).
<input type="text"> → no match.
<button> → no match.
💡
Beginner Tip
Bare $(":checkbox") behaves like $("*:checkbox") and scans every element. Always prefix with input or a form ID: $("#myForm input:checkbox").
No arguments — the pseudo-class matches by input type attribute.
Return value
A jQuery object containing every checkbox input in the search context.
Empty collection when no checkbox inputs exist.
Official jQuery API example
jQuery
var input = $( "form input:checkbox" )
.wrap( "<span></span>" )
.parent()
.css({ background: "yellow", border: "3px red solid" });
$( "div" ).text( "For this type jQuery found " + input.length + "." );
// Official demo matches 2 checkbox inputs in the form
Cheat Sheet
⚡ Quick Reference
Element
input:checkbox
<input type="checkbox">
Matches
<input type="checkbox" checked>
Matches (checked state does not affect selector)
<input type="radio">
No match
<input type="text">
No match
<input> (no type, defaults to text)
No match
Compare
📋 input:checkbox vs :radio and CSS
Form pseudo-classes and the native attribute selector for the same result.
:checkbox
input:checkbox
jQuery pseudo
:radio
input:radio
Different type
Attr
[type='checkbox']
CSS equivalent
Avoid
$(':checkbox')
Implies * scan
Hands-On
Examples Gallery
Example 1 follows the official jQuery API demo. Examples 2–5 cover selector comparison, radio contrast, check-all pattern, and the CSS performance alternative. Use the Try-it links to run each snippet.
📚 Official jQuery Demo
Wrap every checkbox in a form and report how many matched.
Example 1 — Official Demo: form input:checkbox
Official jQuery demo — wrap checkboxes in styled spans and display the match count.
jQuery
var input = $( "form input:checkbox" )
.wrap( "<span></span>" )
.parent()
.css({ background: "yellow", border: "3px red solid" });
$( "#count" ).text( "For this type jQuery found " + input.length + "." );
For this type jQuery found 2.
Both checkboxes wrapped in yellow/red bordered spans
How It Works
jQuery finds checkbox inputs inside the form, wraps each in a span, styles the parent, and returns a collection whose .length is 2 in the official markup.
Example 2 — Compare input:checkbox and [type='checkbox']
Verify that the jQuery pseudo and CSS attribute selector find the same elements.
jQuery
console.log( "input:checkbox →", $( "input:checkbox" ).length );
console.log( "[type=checkbox] →", $( "input[type='checkbox']" ).length );
// Both return the same count on standard checkbox markup
Check #checkAll → all form checkboxes checked
Uncheck → all form checkboxes cleared
How It Works
Scope input:checkbox to the form ID so checkboxes elsewhere on the page stay untouched when the master toggles.
Example 5 — CSS Equivalent input[type='checkbox']
Official jQuery recommendation — same selection with native querySelectorAll support.
jQuery
// Same result as input:checkbox, often faster:
$( "input[type='checkbox']" ).css( "outline", "2px solid #2563eb" );
// Or narrow after a CSS scope:
$( "#form input" ).filter( ":checkbox" );
All checkbox inputs → blue outline
Same elements as input:checkbox
How It Works
Because :checkbox is a jQuery extension, the attribute selector lets jQuery use the browser’s native selector engine on the first pass.
Applications
🚀 Common Use Cases
Check-all — master checkbox toggles every option in a list.
Form styling — highlight all checkbox controls in a settings panel.
Validation — require at least one input:checkbox checked before submit.
Count selected — $("form input:checkbox:checked").length for progress UI.
Disable group — lock all checkboxes during AJAX save.
Reset form — uncheck every checkbox in one scoped query.
🧠 How jQuery Evaluates :checkbox
1
Collect candidates
Start from scoped context — ideally input nodes, not bare :checkbox.
Scope
2
Check type
Match only when type attribute equals checkbox.
Filter
3
Ignore checked state
Selector matches checked and unchecked boxes — use :checked to filter further.
Note
4
☑
Return collection
Matching checkbox inputs become a jQuery object for chaining.
Important
📝 Notes
Available since jQuery 1.0 — jQuery extension, not standard CSS.
Equivalent to $("[type=checkbox]") per official docs.
Bare $(":checkbox") implies $("*:checkbox") — use input:checkbox.
Does not match checked state — combine with :checked when needed.
For performance, prefer input[type="checkbox"] or scoped .filter(":checkbox").
Pair with form context: $("#myForm input:checkbox").
Compatibility
Browser Support
The :checkbox selector ships with jQuery 1.0+. Browser compatibility follows your jQuery version — the pseudo-class itself has no separate native CSS support because it is a jQuery invention.
✓ jQuery 1.0+ · Extension
jQuery :checkbox Selector
Works wherever full jQuery runs — all modern browsers and legacy IE with supported jQuery builds. Not available in querySelectorAll; use input[type='checkbox'] instead.
100%With 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
:checkboxUniversal
Bottom line: Prefer input[type='checkbox'] for native speed. Always scope to a form — never use bare $(':checkbox') on large pages.
Wrap Up
Conclusion
The :checkbox selector matches every <input type="checkbox"> in your search context. The official demo, $("form input:checkbox").wrap(...), wraps checkboxes and reports how many were found.
Write input:checkbox instead of bare :checkbox, and prefer input[type="checkbox"] when you need native selector performance. Scope to a form for check-all and validation patterns.
Use bare $(":checkbox") — it scans like *:checkbox
Expect :checkbox in native querySelectorAll
Confuse :checkbox with :radio
Assume checked boxes are excluded — selector ignores checked state
Toggle every checkbox on the page without scoping the form
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :checkbox
All input type=checkbox elements.
5
Core concepts
:cb01
:checkbox
type=checkbox
API
input02
Prefix
Not bare :
Rule
≠03
Not radio
:radio separate
Compare
all04
Check-all
Common pattern
Use
205
Official
Wrap demo
Demo
❓ Frequently Asked Questions
:checkbox selects every input element whose type attribute is checkbox. It does not select radio buttons, text fields, submit buttons, or other control types.
Prefer $("input:checkbox"). Bare $(":checkbox") implies the universal selector and scans as $("*:checkbox"), which is slower on large pages. Official jQuery docs recommend prefixing with input or another selector.
No. It is a jQuery extension since version 1.0. It is equivalent to $("[type=checkbox]"). For native querySelectorAll performance, use input[type="checkbox"] instead.
:checkbox matches input[type="checkbox"] only. :radio matches input[type="radio"] only. They never overlap — use the correct pseudo-class for each control group.
In the official jQuery form demo, $("form input:checkbox") finds two checkbox inputs and wraps them in styled spans, then reports "For this type jQuery found 2."
Yes. A common pattern is $("#checkAll").on("change", function() { $("form input:checkbox").prop("checked", this.checked); }) — scope to your form so you do not toggle checkboxes elsewhere on the page.
Did you know?
Combine input:checkbox with :checked to select only ticked boxes: $("form input:checkbox:checked"). The base :checkbox selector matches both checked and unchecked inputs — the checked pseudo-class narrows the set.