The disabled
property disables or enables
an option-group.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
optiongroupObject.disabled
Set the disabled property.
optiongroupObject.disabled=true|false
Value | Description |
---|---|
true|false | Enable or disable an option-group
|
A Boolean type value, true if the option-group is disabled, otherwise false.
The following code shows how to check if an option-group is disabled.
<!DOCTYPE html>
<html>
<body>
<!--from w w w. j ava2s.co m-->
<select size="6">
<option value="B">B</option>
<option value="A">A</option>
<optgroup id="myOptgroup" label="My Group" disabled>
<option value="X">X</option>
<option value="T">T</option>
</optgroup>
</select>
<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>
The code above is rendered as follows:
The following code shows how to disable an option-group.
<!DOCTYPE html>
<html>
<body>
<!-- w w w .ja v a 2 s . c o m-->
<select size="6">
<option value="B">B</option>
<option value="A">A</option>
<optgroup id="myOptgroup" label="My Group" disabled>
<option value="X">X</option>
<option value="T">T</option>
</optgroup>
</select>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myOptgroup").disabled = true;
}
</script>
</body>
</html>
The code above is rendered as follows: