jQuery :disabled Selector

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

What You’ll Learn

The :disabled selector matches form elements that are currently disabled — not editable or clickable by the user. Available since jQuery 1.0; pair with :enabled and use .prop("disabled") to change state.

01

Syntax

input:disabled

02

Live

Actual state

03

Official

input:disabled

04

vs [disabled]

Attribute

05

.prop()

Toggle

06

Scope

Not bare :disabled

Introduction

Disabled form controls cannot receive focus or user input — browsers gray them out and skip them on submit (with exceptions for disabled fields that still serialize in some cases). The HTML disabled attribute sets initial state; JavaScript can also toggle disability via the DOM property.

jQuery’s :disabled pseudo-class selects elements that are disabled right now. Official documentation recommends prefixing with a tag or scoped selector — $("input:disabled") instead of bare $(":disabled"), which implies $("*:disabled") and scans every element type.

Understanding the :disabled Selector

Think of :disabled as a live filter on form controls:

  • <input disabled> → matches input:disabled.
  • Enabled input → no match for :disabled.
  • Input inside a disabled <fieldset> → matches :disabled even without its own attribute.
  • button:disabled, select:disabled, textarea:disabled — same pattern.
💡
Beginner Tip

To change disabled state, use .prop("disabled", true/false). Use :disabled to find controls that are already disabled — then style, count, or enable them.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( ":disabled" )



// recommended — prefix with element type:

$( "input:disabled" )

$( "button:disabled" )

$( "#signupForm input:disabled" )

$( "select:disabled" )

Parameters

  • No arguments — filters by current disabled DOM state.

Return value

  • A jQuery object containing every disabled element in the search context.
  • Empty collection when nothing is disabled.

Official jQuery API example

jQuery
// Finds all input elements that are disabled

$( "input:disabled" ).val( "this is it" );

⚡ Quick Reference

Control stateinput:disabledinput[disabled]
disabled attribute on inputMatchesMatches
Enabled inputNo matchNo match (no attribute)
Disabled via parent fieldsetMatches (live state)May not match (no attribute on input)
Attribute present but .prop(false)No match (live state)May still match attribute

📋 :disabled vs [disabled] and :enabled

State pseudo-class vs attribute selector — and the opposite filter.

:disabled
input:disabled

Actually disabled now

[disabled]
input[disabled]

Attribute exists

:enabled
input:enabled

Not disabled

.prop()
.prop("disabled", true)

Set state

Examples Gallery

Example 1 follows the official jQuery input:disabled demo. Examples 2–5 compare with [disabled], count disabled fields, style buttons, and re-enable controls with .prop(). Use the Try-it links to run each snippet.

📚 Official jQuery Demo

Target disabled inputs only — enabled fields are skipped.

Example 1 — Official Demo: input:disabled

Official jQuery demo — set the value on every disabled input.

jQuery
$( "input:disabled" ).val( "this is it" );



// Only disabled inputs change — enabled inputs keep their values
Try It Yourself

How It Works

jQuery collects only inputs whose live disabled property is true, then sets .val() on that subset.

Example 2 — :disabled vs [disabled] with Fieldset

Compare counts when a disabled fieldset disables child inputs without individual attributes.

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

console.log( "[disabled] →", $( "input[disabled]" ).length );



// Fieldset-disabled input matches :disabled, not always [disabled]
Try It Yourself

How It Works

Official jQuery docs note the subtle difference: :disabled reflects actual disability; [disabled] checks markup for the attribute.

📈 Practical Patterns

Counts, styling, and toggling form state.

Example 3 — Count Disabled Fields: $("#form input:disabled").length

Show how many inputs in a form are currently disabled.

jQuery
var n = $( "#signupForm input:disabled" ).length;

$( "#disabledCount" ).text( n + " field(s) disabled" );
Try It Yourself

How It Works

Scoped counting avoids scanning the whole document. Pair with :enabled for the complement set.

Example 4 — Style Disabled Buttons: button:disabled

Add a custom class to every disabled button for consistent UI styling.

jQuery
$( "button:disabled" ).addClass( "btn-muted" );



// Submit disabled until form valid — style the inactive state
Try It Yourself

How It Works

:disabled works on button, not just input. Official docs list all supported element types.

Example 5 — Enable All: Select then .prop("disabled", false)

Find disabled inputs and re-enable them when the user clicks a button.

jQuery
$( "#unlock" ).on( "click", function() {

  $( "#signupForm input:disabled" ).prop( "disabled", false );

});



// :disabled finds; .prop() changes state
Try It Yourself

How It Works

After .prop("disabled", false), those inputs no longer match :disabled — live state drives the selector.

🚀 Common Use Cases

  • Form validation — count or highlight input:disabled vs editable fields.
  • Submit gating — style button:disabled until the form is valid.
  • Wizard steps — disable fields in inactive steps; query with scoped :disabled.
  • Bulk unlock — select disabled set, then .prop("disabled", false).
  • Accessibility audit — list controls that are disabled unexpectedly.
  • Compare state — verify :disabled vs [disabled] after dynamic updates.

🧠 How jQuery Evaluates :disabled

1

Find candidates

Start from scoped inputs — input:disabled, not bare :disabled.

Scope
2

Read property

Test the live disabled property — includes fieldset inheritance.

DOM
3

Filter disabled

Keep only elements that are non-interactive right now.

State
4

Return collection

Matching elements become a jQuery object for chaining.

📝 Notes

  • Available since jQuery 1.0 — matches current disabled state.
  • Use on button, input, select, textarea, optgroup, option, fieldset, menuitem only.
  • Prefer input:disabled over bare $(":disabled") (implies *:disabled).
  • :disabled vs [disabled] — live property vs attribute presence (official docs).
  • Use .prop("disabled") to read or set state — not .attr("disabled").
  • Re-query after toggling — the matched set changes when controls are enabled.

Browser Support

The :disabled pseudo-class is part of CSS3 for form controls and works in jQuery 1.0+. Modern browsers support document.querySelectorAll("input:disabled"). jQuery evaluates live disabled state consistently, including fieldset-disabled descendants.

CSS3 · jQuery 1.0+

jQuery :disabled Selector

Supported in all modern browsers. Native: querySelectorAll("input:disabled"). Reflects live disabled property.

100% Standard + 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
:disabled Universal

Bottom line: Use input:disabled for scoped queries. Pair with .prop() to toggle state, not .attr().

Conclusion

The :disabled selector matches form elements that are disabled right now — not merely those with a disabled attribute in the HTML source. The official input:disabled demo shows how to target that subset for chaining methods like .val().

Prefix with an element type, distinguish from [disabled], and use .prop("disabled") when you need to change state rather than select elements.

💡 Best Practices

✅ Do

  • Use input:disabled or button:disabled
  • Scope to #formId input:disabled
  • Use .prop("disabled") to toggle state
  • Prefer :disabled over [disabled] for live state
  • Re-run selectors after enabling controls

❌ Don’t

  • Use bare $(":disabled") on large documents
  • Rely on .attr("disabled") for live state
  • Apply :disabled to non-form elements
  • Assume [disabled] and :disabled always match the same set
  • Forget fieldset inheritance when counting disabled fields

Key Takeaways

Knowledge Unlocked

Five things to remember about :disabled

Live disabled form controls only.

5
Core concepts
in 02

Prefix

input:disabled

Scope
[] 03

vs attr

Not [disabled]

Compare
.prop 04

Toggle

Not .attr

Tip
demo 05

Official

.val() demo

Demo

❓ Frequently Asked Questions

:disabled matches form elements that are currently disabled — not interactive and typically grayed out by the browser. $("input:disabled") finds every disabled input in the search context. Available since jQuery 1.0.
Official jQuery docs: although results are often similar, :disabled matches elements that are actually disabled while [disabled] only checks whether the disabled attribute exists in the markup. A field inside a disabled fieldset may match :disabled without having its own disabled attribute.
Bare :disabled implies the universal selector — equivalent to $("*:disabled"), which scans every element type. Prefer $("input:disabled"), $("button:disabled"), or $("#form :disabled") for clarity and performance.
Official docs: use :disabled only on elements that support the disabled attribute — button, input, select, textarea, optgroup, option, fieldset, and menuitem.
Use .prop("disabled", true) or .prop("disabled", false) to change state. Use :disabled to find elements that are already disabled. Official docs recommend .prop over .attr for boolean form properties.
:disabled is standard CSS3 for form controls and works in modern querySelectorAll when prefixed with an element type. jQuery has supported it since 1.0.
Did you know?

Disabling a <fieldset> disables all its form controls without adding disabled to each input. $("input:disabled") catches those fields; $("input[disabled]") may miss them — one reason jQuery documents :disabled as the better state selector.

Continue to :enabled Selector

After matching disabled controls, learn the complement — selecting enabled, editable fields.

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