Option disabled attribute
Definition and Usage
disabled
Set or return whether the option in the dropdown list should be disabled.
Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.
See also:
HTML Reference Manual:HTML <option> disabled Attribute
HTML Reference Manual:HTML <option> Tag
Example
Example 1
Disable the third option (index 2) in the dropdown list:
document.getElementById("pets").options[2].disabled = true;
Example 2
Check if the second option (index 1) in the dropdown list is disabled:
var x = document.getElementById("pets").options[1].disabled;
Syntax
Return the disabled attribute:
optionObject.disabled
Set the disabled attribute:
optionObject.disabled = true|false
Attribute Value
Value | Description |
---|---|
true|false |
Specifies whether the option should be disabled in the dropdown list.
|
Technical Details
Return Value: | Boolean value, returns true if the option is disabled; otherwise returns false. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |