English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML 参考手册

HTML 标签大全

HTML optgroup disabled 属性

Disabled属性是布尔属性,如果存在,它指定应该禁用一个选项组,禁用的选项组不可使用且不可单击。

 HTML <optgroup> Tag

在线示例

一个被禁用的选项组:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <optgroup> disabled Attribute - 基础教程网(oldtoolbag.com)</title>
</head>
<body>
<select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars" disabled>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the disabled attribute.

Note:Internet Explorer 7 And earlier versions do not support the disabled attribute of the <optgroup> tag.

Definition and Usage

The Disabled attribute is a boolean attribute.

If present, it specifies that an option group should be disabled.

Disabled option groups cannot be used and cannot be clicked.

Can set the Disabled property to prevent the user from selecting an option group until other conditions are met (such as, checking a checkbox, etc.). Then, JavaScript is needed to remove the disabled values and make the option group selectable.

HTML 4.01 With HTML5Differences

None.

Differences between HTML and XHTML

In XHTML, attribute shorthand is prohibited, the disabled attribute must be defined as <optgroup disabled="disabled">.

Syntax

<optgroup disabled>
 HTML <optgroup> Tag