THE WORLD'S LARGEST WEB DEVELOPER SITE

Option disabled Property

❮ Option Object

Example

Disable the third option (index 2) in a drop-down list:

document.getElementById("pets").options[2].disabled = true;
Try it Yourself »

Definition and Usage

The disabled property sets or returns whether an option in a drop-down list should be disabled, or not.

A disabled element is unusable and un-clickable. Disabled elements are usually rendered in gray by default in browsers.


Browser Support

Property
disabled Yes Yes Yes Yes Yes


Syntax

Return the disabled property:

optionObject.disabled

Set the disabled property:

optionObject.disabled = true|false

Property Values

Value Description
true|false Specifies whether an option in a drop-down list should be disabled or not.
  • true - The option is disabled
  • false - Default. The option is not disabled

Technical Details

Return Value: A Boolean, returns true if the option is disabled, otherwise it returns false

More Examples

Example

Find out if the second option (index 1) in a drop-down list is disabled or not:

var x = document.getElementById("pets").options[1].disabled;
Try it Yourself »

Related Pages

HTML reference: HTML <option> disabled attribute


❮ Option Object