jQuery :checkbox Selector

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is :checkbox?

:checkbox (since jQuery 1.0) selects every element of type checkbox — almost always <input type="checkbox">. Official equivalent: $("[type=checkbox]"). Prefer $("input:checkbox") or $("input[type='checkbox']") over a bare $(":checkbox").

Remember
$("input:checkbox")              // recommended
$("input[type='checkbox']")      // native-friendly CSS
$("[type=checkbox]")             // official equivalent of :checkbox

$(":checkbox")                   // implies *:checkbox — slower

✓ <input type="checkbox">
✗ <input type="radio">
✗ <input type="text">
NeedUse
All checkboxes$("input:checkbox")
Native-friendly$("input[type='checkbox']")
Inside a form$("form input:checkbox")
Radio buttons$("input:radio")
Checked only$("input:checkbox:checked")

How to Use :checkbox

Prefix with input, scope to a form, then count, style, or toggle.

  1. Write $("input:checkbox") — not bare $(":checkbox").
  2. Scope when you can: $("form input:checkbox").
  3. For speed: $("input[type='checkbox']") (official tip).
  4. Combine with :checked when you need only selected boxes.
PieceRequired?Role
Selector stringYes:checkbox (best as input:checkbox)
Tag prefixRecommendedAvoids implied * universal scan
Form / contextRecommendedAvoids checkboxes in unrelated widgets
Return value—jQuery collection of checkbox inputs (may be empty)

Pseudocode

Pseudocode
matches = []
for each element in search context:
    if element.type is "checkbox":
        matches.add(element)

return matches

// Faster pattern:
return querySelectorAll("input[type='checkbox']")

Cheat Sheet

Keep these facts handy while selecting checkbox inputs.

TopicDetail
Syntax$("input:checkbox") / $("form input:checkbox")
SincejQuery 1.0 · jQuery extension
Matchesinput[type=checkbox]
Equivalent$("[type=checkbox]")
Native CSS$("input[type='checkbox']")
AvoidBare $(":checkbox") (implies *)
vs :radioDifferent type — never overlaps
Official demo$("form input:checkbox") → count 2

Live Preview

Run different selectors against a small sample form and see which checkbox inputs match.

Sample markup mirrors the official jQuery form demo (two checkboxes plus radio, text, and a button).

Result
$("input:checkbox")
matched: 2
values: one, two

/* recommended — tag + :checkbox */

jQuery Examples

Short, copy-ready snippets. Open a browser with jQuery loaded, or use Try It Yourself for a live editor.

Example 1 — Official Demo: Count Checkboxes

Find every checkbox in a form and report the count (jQuery API example).

jQuery
var input = $("form input:checkbox");
$("div").text("For this type jQuery found " + input.length + ".");

// Prevent the form from submitting
$("form").on("submit", function (event) {
  event.preventDefault();
});
Try It Yourself

How It Works

  1. Scope. form input:checkbox limits the search to one form.
  2. Filter. Only type="checkbox" inputs match.
  3. Count. .length is written into a message.
  4. Guard. preventDefault stops accidental form submit in the demo.

Example 2 — Prefer input:checkbox

Bare :checkbox implies *:checkbox — always prefix with a tag.

jQuery
console.log("prefixed →", $("input:checkbox").length);
console.log("bare     →", $(":checkbox").length);

// Same count here, but bare form scans every element type
Try It Yourself

How It Works

  1. Docs tip. Pseudo-classes imply * when no tag is given.
  2. Prefix. input:checkbox only considers input elements.
  3. Bare. :checkbox is equivalent to *:checkbox.
  4. Habit. Always write the tag — especially on large pages.

Example 3 — CSS Equivalent [type="checkbox"]

Official tip: use the attribute selector for native querySelectorAll speed.

jQuery
var $a = $("input:checkbox");
var $b = $("input[type='checkbox']");

console.log($a.length === $b.length);
// true — same match set; CSS form is faster
Try It Yourself

How It Works

  1. Same intent. Both selectors target checkbox inputs.
  2. Native path. [type='checkbox'] can use querySelectorAll.
  3. Extension cost. Bare :checkbox cannot use that boost.
  4. Habit. Prefer the CSS form in performance-sensitive code.

Example 4 — :checkbox vs :radio

These pseudo-classes never overlap — each matches one input type.

jQuery
console.log(":checkbox →", $("input:checkbox").length);
console.log(":radio    →", $("input:radio").length);

// Checkboxes and radios are separate type filters
Try It Yourself

How It Works

  1. Type filter. Each pseudo-class reads the input type.
  2. Checkbox. Matches only type="checkbox".
  3. Radio. Matches only type="radio".
  4. Pick one. Use the selector that matches the control you need.

Example 5 — Check / Uncheck All

A common UI pattern: one master checkbox toggles the rest.

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

// Demo: simulate "check all"
$("#checkAll").prop("checked", true).trigger("change");
console.log($("form input:checkbox:checked").length);
Try It Yourself

How It Works

  1. Listen. The master checkbox fires change.
  2. Select. form input:checkbox gathers every box in the form.
  3. Exclude self. .not(this) skips the master when updating others (optional).
  4. Sync. .prop("checked", …) sets the checked state in one call.

Edge Cases & Pitfalls

Check these before relying on :checkbox in real forms.

slow

Bare $(":checkbox") implies *

Official tip: write $("input:checkbox") so the universal selector is not implied.

non-std

Not valid in querySelectorAll

Prefer $("input[type='checkbox']") for native speed.

trap

Radios are not checkboxes

Use :radio for radio inputs — the two selectors never overlap.

state

:checkbox ≠ checked state

It selects all checkboxes, checked or not. Add :checked when you need only selected ones.

Browser Support

The :checkbox pseudo-class is a jQuery extension and has worked since jQuery 1.0. Prefer the CSS equivalent input[type="checkbox"] for native querySelectorAll performance.

✓ jQuery 1.0+ · extension

jQuery :checkbox Selector

Supported across jQuery 1.x, 2.x, and 3.x wherever your jQuery build runs. Prefer input:checkbox; use input[type='checkbox'] for speed.

100% jQuery extension
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: Safe everywhere jQuery runs. Always prefix with input; prefer the attribute selector when performance matters.

Performance Notes

ApproachCostBest for
$("input[type='checkbox']")FastestNative CSS (official tip)
$("form input:checkbox")CheapTypical tutorials and small pages
$("input:checkbox")OKPage-wide checkbox lists
$(":checkbox")SlowerAvoid — implies *:checkbox

Official jQuery docs note that because :checkbox is not CSS, it cannot use the querySelectorAll boost. Use [type="checkbox"] instead when speed matters.

Key Takeaways

  • Role: match every input[type=checkbox].
  • Prefix: write $("input:checkbox"), not bare $(":checkbox").
  • Speed: prefer $("input[type='checkbox']").
  • Not state: add :checked when you need selected boxes only.

One line: use $("input:checkbox") (or the CSS attribute form) to gather checkboxes — never confuse it with :radio or :checked.

Frequently Asked Questions

:checkbox selects every element whose type is checkbox — almost always input[type="checkbox"]. It does not select radio buttons, text fields, 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 a tag name.
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, wraps them, and reports "For this type jQuery found 2."
Yes. A common pattern is $("#checkAll").on("change", function () { $("form input:checkbox").not(this).prop("checked", this.checked); }) — scope to your form so you do not toggle checkboxes elsewhere.

Next: :radio

Select every radio input with the matching jQuery form pseudo-class.

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

9 people found this page helpful