Select disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Select

Description

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

Return Value

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:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials