Javascript DOM HTML OptionGroup disabled Property get

Introduction

Find out if an option-group is disabled or not:

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

Click the button to find out if a group of options in the drop-down list are disabled.

View in separate window

<!DOCTYPE html>
<html>
<body>

<select size="6">
  <option value="CSS">CSS</option>
  <option value="c++">C++</option>
  <optgroup id="myOptgroup" label="Programming Language" disabled>
    <option value="javascript">Javascript</option>
    <option value="html">HTML</option>
    <option value=""sql">SQL</option>
  </optgroup>
</select>/*from  www .  ja  v a  2s.c o  m*/

<button onclick="myFunction()">Test</button>

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

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

</body>
</html>



PreviousNext

Related