Latest web development tutorials
 

Option disabled Property

< Option Object

Example

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

document.getElementById("pets").options[2].disabled = true;

The result will be:

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

Internet Explorer Firefox Opera Google Chrome Safari

The disabled property is supported in all major browsers.


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;

The result of x will be:

true
Try it Yourself »

Related Pages

HTML reference: HTML <option> disabled attribute


< Option Object