jQuery :disabled Selector

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

What Is :disabled?

:disabled (since jQuery 1.0) selects form controls that are actually disabled right now. It is a standard CSS pseudo-class. Official docs note it is subtly different from [disabled], which only checks whether the attribute exists in the markup.

Remember
$("input:disabled")     // disabled inputs
$("button:disabled")    // disabled buttons
$("#form :disabled")    // any disabled control in a form

// :disabled  → actually disabled (live state)
// [disabled] → has a disabled attribute in markup

// Toggle with .prop("disabled", true|false)
NeedUse
Find disabled inputs$("input:disabled")
Find enabled inputs$("input:enabled")
Change disabled state.prop("disabled", true)
Attribute present only$("input[disabled]")
All inputs$(":input") / $("input")

How to Use :disabled

Prefix with a tag or form context, then read or update the disabled set.

  1. Prefer $("input:disabled") or $("#form :disabled") over bare $(":disabled").
  2. Use it on elements that support disabled (input, button, select, textarea, …).
  3. Re-query after toggles — state is live, not a one-time snapshot of HTML.
  4. Change state with .prop("disabled", true|false), not .attr().
  5. Remember :disabled ≠ [disabled] when fieldsets inherit disabled state.
PieceRequired?Role
:disabledYesMatches currently disabled controls
Tag / form scopeRecommendedAvoids a universal * scan
Supported elements—button, input, select, textarea, option, fieldset, …
Return value—jQuery collection of matching elements

Pseudocode

Pseudocode
matches = []
for each element in search context:
    if element supports disabled
       and element is currently disabled:   // live property / inherited
        matches.add(element)

return matches

// [disabled] only checks: hasAttribute("disabled")

Cheat Sheet

Keep these facts handy while working with disabled controls.

TopicDetail
Syntax$("input:disabled")
SincejQuery 1.0 · CSS standard
Live stateMatches currently disabled controls
vs [disabled]Attribute presence only
Opposite:enabled
Toggle.prop("disabled", true|false)
Bare formAvoid $(":disabled") → universal scan
Empty setNothing disabled → length 0

Live Preview

Toggle which fields are disabled, then run $("input:disabled").

Disable these inputs

Same idea as the official demo — match inputs that are currently disabled.

Result
$("input:disabled").length
→ 2

matched → a=alpha, c=charlie

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Official $("input:disabled")

Set a value on every disabled input — the official demo pattern.

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

var lines = [];
$("input").each(function () {
  lines.push(this.name + " = " + this.value +
    (this.disabled ? " [disabled]" : ""));
});
$("#out").text(lines.join("\n"));
Try It Yourself

How It Works

  1. Select. $("input:disabled") finds currently disabled inputs.
  2. Write. .val("this is it") updates only that set.
  3. Skip. Enabled inputs keep their original values.
  4. Report. We print each field so you can compare results.

Example 2 — Count Disabled Controls

Compare disabled vs enabled counts on the same form.

jQuery
$("#out").text(
  "Disabled: " + $("input:disabled").length + "\n" +
  "Enabled: " + $("input:enabled").length
);
Try It Yourself

How It Works

  1. Disabled. :disabled counts locked fields.
  2. Enabled. :enabled is the opposite set.
  3. Together. On a form of only inputs, the two counts usually add up to all inputs.
  4. Use. Handy for validation summaries and UI badges.

Example 3 — :disabled vs [disabled]

Official subtlety: live disabled state vs attribute presence.

jQuery
$("#out").text(
  ":disabled → " + $("#box input:disabled").length + "\n" +
  "[disabled] → " + $("#box input[disabled]").length
);
Try It Yourself

How It Works

  1. Attribute. [disabled] needs the attribute on that element.
  2. Live. :disabled also matches controls disabled via a parent fieldset.
  3. Difference. Counts can diverge in nested disabled groups.
  4. Prefer. Use :disabled when you care about real interactivity.

Example 4 — Toggle with .prop()

Find with :disabled; change state with .prop("disabled", …).

jQuery
$("#lock").on("click", function () {
  $("#name").prop("disabled", true);
  $("#out").text("Disabled count: " + $("input:disabled").length);
});

$("#unlock").on("click", function () {
  $("#name").prop("disabled", false);
  $("#out").text("Disabled count: " + $("input:disabled").length);
});
Try It Yourself

How It Works

  1. Lock. .prop("disabled", true) disables the field.
  2. Find. $("input:disabled") now includes it.
  3. Unlock. .prop("disabled", false) restores interaction.
  4. Rule. Prefer .prop over .attr for boolean form state.

Example 5 — Scoped Form Query

Limit the search so other forms on the page stay untouched.

jQuery
var n = $("#signup :disabled").length;
var all = $(":disabled").length;

$("#out").text(
  "Inside #signup: " + n + "\n" +
  "Whole page (avoid bare): " + all
);
Try It Yourself

How It Works

  1. Scope. #signup :disabled only searches that form.
  2. Bare. $(":disabled") can include other regions.
  3. Habit. Always scope on multi-form pages.
  4. Types. This also matches disabled buttons/selects inside the form.

Edge Cases & Pitfalls

Check these before relying on :disabled in real forms.

attr

:disabled ≠ [disabled]

Attribute selectors only check markup. Live disabled state (including via a disabled fieldset) is what :disabled uses.

bare

Bare $(":disabled") scans everything

Official docs recommend a tag or other prefix. Prefer $("input:disabled") or a form scope.

elements

Only supported controls

Use it on button, input, select, textarea, option, fieldset, and similar — not arbitrary divs.

prop

Toggle with .prop(), not .attr()

Boolean form state belongs on the property. After toggling, re-run :disabled to refresh counts.

Browser Support

The :disabled pseudo-class is standard CSS and has been in jQuery since 1.0. It works wherever your jQuery build runs.

✓ Stable · CSS · jQuery 1.0+

jQuery :disabled

Supported across jQuery 1.x, 2.x, and 3.x in every browser that runs your jQuery build. Prefer current jQuery 3.x for modern projects.

100% Form selector support
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: Safe everywhere jQuery runs. Prefer a tag or form prefix, and use :disabled (not only [disabled]) for live state.

Performance Notes

ApproachCostBest for
$("#form input:disabled")CheapestScoped forms
$("input:disabled")CheapTypical pages
$(":disabled")SlowerAvoid — universal scan
$("input[disabled]")CheapAttribute-only checks

Cost is rarely the issue on small forms. Prefixing and scoping matter more for clarity and on pages with many controls.

Key Takeaways

  • Role: match form controls that are disabled right now.
  • Prefix: prefer $("input:disabled") over bare $(":disabled").
  • vs attr: :disabled is live state; [disabled] is markup only.
  • Toggle: use .prop("disabled", …); find with :disabled.

One line: :disabled finds live disabled controls — prefix with a tag, scope to a form, and toggle with .prop().

Frequently Asked Questions

:disabled matches form elements that are currently disabled — not interactive. $("input:disabled") finds every disabled input in the search context. Available since jQuery 1.0.
Official jQuery docs: results are often similar, but :disabled matches elements that are actually disabled while [disabled] only checks whether the disabled attribute exists. A control inside a disabled fieldset may match :disabled without 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").
Official docs: use it for 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. Prefer .prop over .attr for boolean form properties.
Yes. :disabled is a standard CSS pseudo-class for form controls. jQuery has supported it since 1.0. Prefer a tag prefix for clarity and performance.

Next: :enabled Selector

Learn how to match form controls that are currently enabled and interactive.

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

8 people found this page helpful