HTML元素 OPTGROUP
方工 2003-08-05 09:57:09 OPTGROUP 为W3C HTML4的标准元素,现在IE6也支持:
http://www.w3.org/TR/html401/interact/forms.html#edef-OPTGROUP
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/optgroup.asp
http://www.htmlhelp.com/reference/html40/forms/optgroup.html
的注解:
OPTGROUP is not well supported by current browsers, but its design allows authors to use it today without sacrificing compatibility with non-supporting browsers. Supporting browsers will render the preceding example using the LABEL attribute of OPTION to provide just the version number, along with the OPTGROUP's LABEL, which gives the full name of the application. This allows a compact display with easy-to-use cascading menus.
Non-supporting browsers will ignore the OPTGROUP elements and LABEL attributes, providing the full name and version for each choice. Thus authors can fully use OPTGROUP despite its lack of browser support.
Note that, in HTML 4.0, OPTGROUP is limited to containing only OPTION elements, thus preventing nested OPTGROUPs with multi-level cascades. Future versions of HTML may add support for nested option groups.
The boolean DISABLED attribute makes the option group unavailable. The options of a disabled option group cannot be selected by the user and are never submitted with the form.
例:
<select name="filter">
<option value="">请选择...</option>
<optgroup label="---------------------">
</optgroup>
<optgroup label="手机">
<option value="c1">诺基亚</option>
<option value="c2">摩托罗拉</option>
<option value="c3">三星</option>
</optgroup>
<optgroup label="电视">
<option value="r1">康佳</option>
<option value="r2">长虹</option>
</optgroup>
<optgroup label="---------------------">
</optgroup>
<option value="s1">热销产品TOP 10</option>
<option value="all">所有产品</option>
</select>