OptionGroup disabled 属性

定义和用法

disabled 属性设置或返回选项组是否被禁用。

禁用的元素不可用且不可点击。默认情况下,禁用的元素通常在浏览器中呈现为灰色。

另请参阅:

HTML 参考手册:HTML <optgroup> disabled attribute

HTML 参考手册:HTML <optgroup> tag

实例

例子 1

禁用选项组:

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

亲自试一试

例子 2

查看选项组是否被禁用:

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

亲自试一试

语法

返回 disabled 属性:

optiongroupObject.disabled

设置 disabled 属性:

optiongroupObject.disabled = true|false

属性值

Value Description
true|false

Specifies whether the option group should be disabled.

  • true - The option group is disabled
  • false - Default. The option group is not disabled

Technical details

Return value: Boolean value, returns true if the option group is disabled; otherwise returns false.

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support