HTML | DOM Option disabled Property
The DOM Option disabled Property is used to set or return whether the value of an option would be disabled or not. The disabled attribute for the element in HTML is used to specify that the option value is disabled. A disabled option is un-clickable and unusable. It is a boolean attribute.
Syntax:
- It is used to return the disabled property.
optionObject.disabled
- It is used to set the disabled property.
optionObject.disabled = true|false
Property Values:
- true:It defines that option is disabled.
- false: It defines that option value is not disabled. It has a Default value.
Return Value: It returns a boolean value which represent that option value is disabled or not.
Example-1: This Example illustrate how to set the Property.
<!DOCTYPE html> <html> <head> <title>DOM option disabled Property</title> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM option disabled Property</h2> <select id="GFG"> <option>Choose an option</option> <option value="html">HTML</option> <option value="java">JAVA</option> <option value="C++">C++</option> <option value="php">PHP</option> <option value="perl">PERL</option> </select> <br> <br> <br> <br> <br> <br> <br> <button onclick="myGeeks()">Submit</button> <script> function myGeeks() { // Set disabled property "true". var x = document.getElementById( "GFG").options[2].disabled = true; } </script> </body> </html> |
Output :
Before Clicking On Button :

After Clicking On Button:

Example-2 : This Example illustrate how to return the disabled property.
<!DOCTYPE html> <html> <head> <title>DOM option disabled Property</title> <style> body { text-align: center; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM option disabled Property</h2> <select id="GFG"> <option>Choose an option</option> <option value="html">HTML</option> <option value="java">JAVA</option> <option value="C++">C++</option> <option value="php">PHP</option> <option value="perl">PERL</option> </select> <br> <br> <br> <br> <br> <br> <br> <button onclick="myGeeks()">Submit</button> <p id="sudo" style="font-size:25px;color:green;"> </p> <script> function myGeeks() { // Return disabled property. var x = document.getElementById( "GFG").options[2].disabled; document.getElementById("sudo").innerHTML = x; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by DOM option disabled Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML <option> disabled Attribute
- HTML | DOM Option value Property
- HTML | DOM Option defaultSelected Property
- HTML | DOM Option label Property
- HTML | DOM option index Property
- HTML | DOM Option form Property
- HTML | DOM Option text Property
- HTML | DOM Option selected Property
- HTML | DOM Link disabled Property
- HTML | DOM OptionGroup disabled Property
- HTML | DOM Fieldset disabled Property
- HTML | DOM Textarea disabled Property
- HTML | DOM Input URL disabled Property
- HTML | DOM Button disabled Property
- HTML | DOM Select disabled Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : shubham_singh



