Open In App

HTML DOM OptionGroup disabled Property

The OptionGroup disabled Property in HTML DOM is used to set or return the OptionGroup disabled property. This property checks whether the OptGroup is disabled or not. A disabled <optgroup> element is un-clickable and unusable. It is a Boolean attribute. 

Syntax: 



optiongroupObject.disabled
optiongroupObject.disabled = true|false

Property Values: 

Return Value: It returns a Boolean value that represents whether an OptionGroup is disabled or not. 



Example 1: In this example, we will see the use of DOM OptionGroup disabled Property




<!DOCTYPE html>
<html>
   
<head>
    <title>
        HTML DOM OptionGroup disabled Property
    </title>
</head>
 
<body style="text-align:center">
    <h1 style="color: green;">
          GeeksforGeeks
      </h1>
    <h2>HTML DOM optgroup disabled Property</h2>
    <select>
        <!--A disabled optgroup-->
        <optgroup id="GFG" label="Sorting Algorithms" k
                  disabled>
            <option value="merge">Merge sort</option>
            <option value="quick">Quick sort</option>
        </optgroup>
    </select>
    <br><br>
    <button onclick="myGeeks()">Try it</button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            let g = document.getElementById("GFG").disabled;
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
</body>
 
</html>

Output: 

 

Example 2: In this example, we will see the use of DOM OptionGroup disabled Property




<!DOCTYPE html>
<html>
   
<head>
    <title>
        HTML DOM OptionGroup disabled Property
    </title>
</head>
 
<body style="text-align:center">
    <h1 style="color: green;">
          GeeksforGeeks
      </h1>
    <h2>HTML DOM optgroup disabled Property</h2>
    <select>
        <!--A disabled optgroup-->
        <optgroup id="GFG" label="Sorting Algorithms"
                  disabled>
            <option value="merge">Merge sort</option>
            <option value="quick">Quick sort</option>
        </optgroup>
    </select>
    <br><br>
    <button onclick="myGeeks()">Try it</button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
           let g = document.getElementById("GFG").disabled
                = "false";
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
</body>
 
</html>

Output: 

 

Supported Browsers: The browsers supported by HTML DOM OptionGroup disabled Property are listed below: 


Article Tags :