jQuery :checkbox Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

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

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("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">
CallWhat it does
Selector string:checkbox (best as input:checkbox)
Tag prefixAvoids implied * universal scan
Form / contextAvoids checkboxes in unrelated widgets
Return valuejQuery collection of checkbox inputs (may be empty)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Write $("input:checkbox") — not bare $(":checkbox").
Step 2Scope when you can: $("form input:checkbox").
Step 3For speed: $("input[type='checkbox']") (official tip).

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

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.

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.

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.

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 Selector — Select Radio Buttons

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

:radio Selector — Select Radio Buttons tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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