无涯教程-HTML - <optgroup>属性

39 阅读1分钟

HTML <optgroup>标签用于将选择列表中的相关选项分组。

optgroup 示例

<!DOCTYPE html>
<html>

   <head>
      <title>HTML optgroup Tag</title>
   </head>

   <body>
      <select>
         <optgroup label="India">
            <option value="mumbai">Mumbai</option>
            <option value="delhi">Delhi</option>
         </optgroup>
         
         <optgroup label="USA">
            <option value="florida">Florida</option>
            <option value="newyork">New York</option>
         </optgroup>
      </select>
   </body>
   
</html>

这将产生以下结果-

全局属性

此标签支持- HTML 中所述的所有全局属性。

特定属性

HTML <optgroup>标签还支持以下其他属性-

Attribute Value 描述
disabled disabled 禁用输入控件。该按钮将不接受用户的更改。它也无法获得焦点,并且在按Tab键时将被跳过。
label text 定义使用<optgroup>时要使用的标签。

事件属性

此标签支持- HTML 中所述的所有事件属性。

浏览器支持

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes Yes

参考链接

www.learnfk.com/html/html-o…