OptionGroup disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:OptionGroup

Description

The disabled property sets or gets whether an option-group is disabled.

Set the disabled property with the following Values

Value Description
true|false Sets whether an option-group should be disabled

Return Value

A Boolean, returns true if the option-group is disabled, otherwise it returns false

The following code shows how to disable an option-group:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<select size="6">
  <option value="B">B</option>
  <option value="M">M</option>
  <optgroup id="myOptgroup" label="Web">
    <option value="css">CSS</option>
    <option value="html">HTML</option>
    <option value="sql">SQL</option>
  </optgroup>
</select>//w  ww.  j a  v a  2s  . c o m

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

<script>
function myFunction() {
    document.getElementById("myOptgroup").disabled = true;
}
</script>

</body>
</html>

Related Tutorials