jQuery :disabled Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

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

Syntax

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

jQuery
$("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)
CallWhat it does
:disabledMatches currently disabled controls
Tag / form scopeAvoids a universal * scan
Supported elementsbutton, input, select, textarea, option, fieldset, …
Return valuejQuery collection of matching elements

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

Parameters

ParameterDescription
Step 1Prefer $("input:disabled") or $("#form :disabled") over bare $(":disabled").
Step 2Use it on elements that support disabled (input, button, select, textarea, …).
Step 3Re-query after toggles — state is live, not a one-time snapshot of HTML.

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.

jQuery Examples

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.

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.

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.

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 — Enabled Form Controls

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

:enabled Selector — Enabled Form Controls 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.

8 people found this page helpful