jQuery :radio Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

:radio (since jQuery 1.0) selects every <input type="radio"> — the one-choice-per-group controls used in surveys, settings, and checkout. Official docs state it is equivalent to [type=radio]. Always prefer $("input:radio") over bare $(":radio").

Syntax

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

jQuery
$("input:radio")                 // all radio inputs
$("form input:radio")            // radios inside a form
$("input[name=gender]:radio")    // one radio group (official)
$("input[type=radio]")           // equivalent attribute form

// Avoid on large pages:
$(":radio")                      // implies *:radio
CallWhat it does
Selector string:radio filter (best with an input prefix)
name attributeLimits matches to one mutually exclusive group
Form / contextAvoids radios in unrelated widgets
Return valuejQuery collection of matching radio 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:radio") — never bare $(":radio") on large pages.
Step 2Scope to a form: $("#survey input:radio").
Step 3Target one group with the official pattern: $("input[name=gender]:radio").

Return Value

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

jQuery Examples

Example 1 — Official Demo: form input:radio

Wrap radios in styled spans and print the match count (jQuery API example).

jQuery
var input = $("form input:radio")
  .wrap("<span></span>")
  .parent();

$("#count").text("For this type jQuery found " + input.length + ".");
Try It Yourself

How It Works

  1. Scope. form input:radio searches radios inside the form only.
  2. Filter. Only type="radio" matches — other inputs are ignored.
  3. Wrap. Each match gets a <span> parent for styling.

Example 2 — Equivalence: :radio vs [type=radio]

Official docs — both forms select the same elements.

jQuery
var a = $("input:radio").length;
var b = $("input[type=radio]").length;

console.log("input:radio →", a);
console.log("[type=radio] →", b);
console.log("same set?", a === b);
Try It Yourself

How It Works

  1. Pseudo. :radio is the jQuery shorthand for radio-type inputs.
  2. Attribute. [type=radio] is the standard CSS equivalent.
  3. Compare. Matching lengths mean both forms found the same nodes.

Example 3 — input:radio vs input:checkbox

Mark each control type separately — the selectors never overlap.

jQuery
$("input:radio").closest("label").each(function () {
  this.appendChild(document.createTextNode(" [radio]"));
});
$("input:checkbox").closest("label").each(function () {
  this.appendChild(document.createTextNode(" [checkbox]"));
});

console.log("radios:", $("input:radio").length);
console.log("checkboxes:", $("input:checkbox").length);
Try It Yourself

How It Works

  1. Type filter. :radio keeps radio inputs only.
  2. Other type. :checkbox keeps checkbox inputs only.
  3. No overlap. A control never matches both selectors.

Frequently Asked Questions

:radio selects every input whose type is radio — mutually exclusive options in a form group. $("input:radio") finds all radio buttons in the search context. Available since jQuery 1.0.
Prefer $("input:radio"). Bare $(':radio') implies the universal selector and scans as $('*:radio'), which is slower on large pages. Official jQuery docs recommend prefixing with input or another selector.
Yes. Official docs state that :radio is equivalent to $('[type=radio]'). For native querySelectorAll performance in modern browsers, prefer input[type="radio"] over the :radio pseudo-class.
:radio matches input[type="radio"] only. :checkbox matches input[type="checkbox"] only. They never overlap — use the correct pseudo-class for each control type.
Official docs example: $("input[name=gender]:radio") selects radio buttons with name="gender" only. Combine the name attribute filter with :radio to target a single mutually exclusive group.
No. It is a jQuery extension (not part of the CSS specification), so queries using :radio cannot use the native querySelectorAll boost. Use [type="radio"] when performance matters.

Next: :file Selector — Select File Inputs

Learn how to select file upload inputs in forms with the :file selector.

:file Selector — Select File Inputs 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