OptionGroup disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:OptionGroup


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>

<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>
</select>//w  ww.  j a  v a  2s  . c o m

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

function myFunction() {
    document.getElementById("myOptgroup").disabled = true;


Related Tutorials