Latest web development tutorials

HTML DOM OptionGroup disabled property

OptionGroup Object Reference OptionGroup objects

Examples

Disable an option-group:

document.getElementById("myOptgroup").disabled=true;

Output:

BMW Mercedes Volvo Saab Koenigsegg

try it"

Definition and Usage

disabled property sets or returns whether to disable the option group.

Disabled elements are not available, and do not click. By default, the disabled elements typically exhibit gray in your browser.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the disabled attribute.


grammar

Returns disabled properties:

optiongroupObject .disabled

Set the disabled attribute:

optiongroupObject .disabled=true|false

Property Value

描述
true|false 规定选项组是否是禁用的。
  • true - The option-group is disabled
  • false - 默认。选项组是不禁用的。

technical details

return value: Boolean value that, if the group option is disabled, it returns true, otherwise returns false.


More examples

Examples

Check that option group is disabled:

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

x The output is:

true

try it"


related articles

HTML Reference Manual: HTML <optgroup> Disabled Property


OptionGroup Object Reference OptionGroup objects