jQuery :checkbox Selector

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

What You’ll Learn

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]

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.

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").

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( "input:checkbox" )
// shorthand:
$( "input:checkbox" )

// scoped (recommended):
$( "form input:checkbox" )
$( "#preferences input[type='checkbox']" ) // CSS equivalent

Parameters

  • 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

⚡ Quick Reference

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

📋 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

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

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

How It Works

Official docs state :checkbox is equivalent to [type=checkbox]. The attribute form works in native querySelectorAll.

📈 Practical Patterns

Radio contrast, check-all wiring, and performance-friendly CSS.

Example 3 — input:checkbox vs input:radio

Style checkboxes without affecting radio buttons in the same form.

jQuery
$( "input:checkbox" ).addClass( "cb-highlight" );
$( "input:radio" ).addClass( "radio-highlight" );

// :checkbox → input[type=checkbox] only
// :radio → input[type=radio] only
Try It Yourself

How It Works

Each form pseudo-class maps to one input type. Mixing them lets you style toggle controls independently in the same fieldset.

Example 4 — Check-All Pattern with $("#checkAll")

Toggle every checkbox in a form when the master control changes.

jQuery
$( "#checkAll" ).on( "change", function() {
  $( "#prefsForm input:checkbox" ).prop( "checked", this.checked );
});

// Master checkbox controls all others in #prefsForm
Try It Yourself

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

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.

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

📝 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").

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 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
:checkbox Universal

Bottom line: Prefer input[type='checkbox'] for native speed. Always scope to a form — never use bare $(':checkbox') on large pages.

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.

💡 Best Practices

✅ Do

  • Use input:checkbox or input[type='checkbox']
  • Scope: $("#form input:checkbox") on large pages
  • Combine with :checked to count selections
  • Use check-all scoped to one form ID
  • Prefer attribute selector for native performance

❌ Don’t

  • 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

Key Takeaways

Knowledge Unlocked

Five things to remember about :checkbox

All input type=checkbox elements.

5
Core concepts
input 02

Prefix

Not bare :

Rule
03

Not radio

:radio separate

Compare
all 04

Check-all

Common pattern

Use
2 05

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.

Continue to :radio Selector

Learn how to select mutually exclusive radio button groups in forms.

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