jQuery :radio Selector

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

What You’ll Learn

The :radio selector matches every <input type="radio"> element — mutually exclusive options in form groups. Available since jQuery 1.0; equivalent to [type=radio]; always prefer input:radio over bare :radio.

01

Syntax

input:radio

02

type=radio

One choice

03

Official

Wrap + count

04

name=

Group scope

05

vs :checkbox

Different type

06

Native CSS

Faster query

Introduction

Surveys, settings panels, and checkout flows use radio buttons when users must pick exactly one option from a set. jQuery’s :radio pseudo-class selects every input whose type attribute is radio.

Official jQuery documentation notes that :radio is equivalent to [type=radio], and recommends prefixing with input — bare $(":radio") implies $("*:radio"). To target one group, combine name with the pseudo-class: $("input[name=gender]:radio").

Understanding the :radio Selector

Think of :radio as a shortcut for radio-type inputs only:

  • input:radio → every radio button in scope.
  • input[name=size]:radio → one mutually exclusive group.
  • input:checkbox → different type — no overlap with :radio.
  • Only one radio per name can be checked at a time in standard HTML forms.
💡
Beginner Tip

Scope to your form: $("#survey input:radio") avoids styling radio buttons in unrelated modals on the same page.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( ":radio" )

// recommended — prefix with input:
$( "input:radio" )
$( "form input:radio" )

// one radio group (official docs example):
$( "input[name=gender]:radio" )

// equivalent attribute form:
$( "input[type=radio]" )

// native CSS (better performance):
document.querySelectorAll( 'input[type="radio"]' )

// avoid on large pages:
$( ":radio" )   // implies *:radio

Parameters

  • No arguments — keeps elements whose type is radio.

Return value

  • A jQuery object containing every matching radio input (zero or more).

Official jQuery API example

jQuery
var input = $( "form input:radio" )
  .wrap( "<span></span>" )
  .parent()
  .css({ background: "yellow", border: "3px red solid" });

$( "div" ).text( "For this type jQuery found " + input.length + "." )
  .css( "color", "red" );

⚡ Quick Reference

Elementinput:radioinput[type="radio"]
<input type="radio" name="a">MatchesMatches
<input type="checkbox">No matchNo match
input[name=gender]:radioOne groupUse both filters
:checked on radiosSelected onlyCombine selectors
Native querySelectorAllNot supportedSupported

📋 :radio vs :checkbox and [type="radio"]

Mutually exclusive groups vs multi-select toggles.

:radio
input:radio

One choice per name

:checkbox
input:checkbox

Multi-select toggles

[type=radio]
input[type="radio"]

Native CSS — faster

:checked
input:radio:checked

Selected in group

Examples Gallery

Example 1 follows the official jQuery form input:radio demo. Examples 2–5 cover attribute equivalence, contrast with :checkbox, name-scoped groups, and the native performance pattern.

📚 Official jQuery Demo

Wrap every radio in a form and report how many matched.

Example 1 — Official Demo: form input:radio

Official jQuery demo — wrap radios in styled spans and display the match count in red.

jQuery
var input = $( "form input:radio" )
  .wrap( "<span></span>" )
  .parent()
  .css({ background: "yellow", border: "3px red solid" });

$( "div" ).text( "For this type jQuery found " + input.length + "." )
  .css( "color", "red" );

$( "form" ).on( "submit", function( e ) { e.preventDefault(); } );
Try It Yourself

How It Works

jQuery finds radio inputs inside the form, wraps each in a span, styles the wrapper, and reports .length.

Example 2 — Equivalence: [type=radio]

Official docs — :radio and the attribute selector find the same elements.

jQuery
console.log( "input:radio →", $( "input:radio" ).length );
console.log( "[type=radio] →", $( "input[type=radio]" ).length );
Try It Yourself

How It Works

Both forms select the same DOM nodes — choose attribute syntax when native speed matters.

📈 Practical Patterns

Checkbox contrast, group scoping, and native queries.

Example 3 — input:radio vs input:checkbox

Style radio buttons without affecting checkboxes in the same fieldset.

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

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

How It Works

Each form pseudo-class maps to one input type — they never overlap.

Example 4 — Group Scope: input[name=gender]:radio

Official docs — select one mutually exclusive radio group by name.

jQuery
$( "input[name=gender]:radio" ).on( "change", function() {
  $( "#genderOut" ).text( "Selected: " + this.value );
});

// size group radios are not affected
Try It Yourself

How It Works

Combining name with :radio limits the matched set to one HTML radio group.

Example 5 — Native Performance: input[type="radio"]

Official docs — use attribute selector in modern browsers for querySelectorAll speed.

jQuery
$( "input[type='radio']" ).addClass( "option" );

// Pure DOM (no jQuery pseudo-class):
document.querySelectorAll( "input[type='radio']" );
Try It Yourself

How It Works

Because :radio is not standard CSS, attribute matching lets the browser optimize the query.

🚀 Common Use Cases

  • Survey forms — style or validate input:radio groups.
  • Settings panels — read input[name=theme]:radio:checked.
  • Checkout — highlight shipping option radios on change.
  • Accessibility — pair with <label> elements per group.
  • Dynamic UI — enable/disable sections based on selected radio value.
  • Performance — prefer input[type="radio"] in hot paths.

🧠 How jQuery Evaluates :radio

1

Parse selector

Combine input with :radio — optionally add [name=...].

Query
2

Find candidates

Collect input elements in scope (or all elements if bare :radio).

Scan
3

Filter by type

Keep inputs where type attribute equals radio.

Match
4

Return collection

Chain .prop(), .on("change"), or styling methods.

📝 Notes

  • Available since jQuery 1.0 — equivalent to [type=radio].
  • jQuery extension only — not valid in native querySelectorAll(":radio").
  • Always use input:radio — bare :radio implies universal scan.
  • Official group pattern — input[name=gender]:radio.
  • Does not match checkboxes, text fields, or submit buttons.
  • Combine with :checked to read the selected option in a group.

Browser Support

The :radio pseudo-class is a jQuery extension and works in jQuery 1.0+. The equivalent input[type="radio"] attribute selector is standard CSS and runs in native querySelectorAll in all modern browsers.

jQuery 1.0+ · extension

jQuery :radio Selector

Use input:radio in jQuery; use input[type="radio"] for native speed.

100% jQuery + native attr
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
:radio Universal

Bottom line: Scope groups with input[name=group]:radio; prefer [type="radio"] when performance matters.

Conclusion

The :radio selector matches every input type="radio" element — the official demo wraps them in styled spans and reports the match count.

Prefix with input, scope groups with name, and use [type="radio"] when you need native query performance.

💡 Best Practices

✅ Do

  • Write $("#form input:radio") for scoped queries
  • Use input[name=group]:radio for one group
  • Pair with :checked to read selection
  • Use input[type="radio"] for native performance
  • Wrap radios in <label> for accessibility

❌ Don’t

  • Use bare $(":radio") on large pages
  • Expect :radio in querySelectorAll
  • Confuse :radio with :checkbox selectors
  • Assume all radios share one selection — check name
  • Style without scoping when multiple forms exist

Key Takeaways

Knowledge Unlocked

Five things to remember about :radio

Radio-type inputs only.

5
Core concepts
= 02

[type=]

Equivalent

Rule
name 03

Group

Scope it

Tip
04

≠ checkbox

Separate

Compare
demo 05

Official

Wrap count

Demo

❓ Frequently Asked Questions

:radio selects every input element whose type attribute is radio — mutually exclusive options in a 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 jQuery 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.
The official jQuery form demo wraps $("form input:radio") in styled spans and reports how many were found — typically two radio inputs among checkboxes, text fields, and other controls in the sample form.
Did you know?

Official jQuery input-type demos share the same pattern for checkbox, file, password, radio, and others: wrap or style matched inputs, print For this type jQuery found N., and call event.preventDefault() on form submit so the demo page does not reload.

Continue to :file Selector

Learn how to select file upload inputs in forms.

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