Javascript DOM HTML Select disabled Property get

Introduction

Find out if a drop-down list is disabled or not:

var x = document.getElementById("mySelect").disabled;

Click the button to find out if the dropdown list is disabled.

View in separate window

<!DOCTYPE html>
<html>
<body>

<select id="mySelect" disabled>
  <option>CSS</option>
  <option>Java</option>
  <option>HTML</option>
</select>/*from   w ww . j  av  a 2  s.  c  o m*/
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("mySelect").disabled;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related