Javascript examples for DOM HTML Element:Select
The disabled property sets or gets whether a drop-down list should be disabled.
This property reflects the HTML disabled attribute.
Set the disabled property with the following Values
Value | Description |
---|---|
true|false | Sets whether a drop-down list should be disabled |
A Boolean, returns true if the drop-down list is disabled, otherwise it returns false
The following code shows how to disable a drop-down list:
<!DOCTYPE html> <html> <body> <form> <select id="mySelect"> <option>HTML</option> <option>CSS</option> </select>//from w w w . ja v a 2 s . c o m </form> <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("mySelect").disabled = true; } </script> </body> </html>