Option disabled Property - Find out if the second option (index 1) in a drop-down list is disabled - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Option

Description

Option disabled Property - Find out if the second option (index 1) in a drop-down list is disabled

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<select id="pets" size="3">
  <option>Cat</option>
  <option>Dog</option>
  <option>Horse</option>
</select>// w  w w .j a  v  a2s  .c om

<button onclick="myFunction()">Disable Option</button>

<script>
function myFunction() {
    var x = document.getElementById("pets").options[2].disabled;
    console.log(x);
}
</script>

</body>
</html>

Related Tutorials