Home >Web Front-end >HTML Tutorial >About the use of select optgroup tag in html

About the use of select optgroup tag in html

黄舟
黄舟Original
2017-07-03 09:32:471717browse

Occasionally I need to group the select content. In the past, I used program control. Today I found that there is an optgroup attribute in the select that can be used. My experience in the trial As follows, interested friends can refer to it Occasionally, I need to group select content. In the past, I used program control. Today I found that there is an optgroup attribute in select that can be used.

It has been tested and suitable for browsers such as firefox and ie. The only shortcoming found so far is that the title style after the group cannot be customized. For example: If you want to change the font attributes, you cannot use a normal font, but you can change the color and size. The default under IE is italic and bold

The code is as follows:

<select name="bid" id="brand_3"> 
<option value="">请选择品牌</option> 
<optgroup label="A"></optgroup> 
<option value="693" custom="693">A AC宝马</option> 
<option value="62" custom="62">A 阿斯顿马丁</option> 
<option value="1" custom="1">A 奥迪</option> 
<optgroup label="B"></optgroup> 
<option value="723" custom="723">B 巴博斯</option> 
<option value="44" custom="44">B 保时捷</option> 
<option value="582" custom="582">B 宝骏</option> 
<option value="20" custom="20">B 宝马</option> 
<option value="593" custom="593">B 北京汽车</option> 
<option value="643" custom="643">B 北汽威旺</option> 
<option value="122" custom="122">B 北汽制造</option> 
<option value="4" custom="4">B 奔驰</option> 
</select>


The above is the detailed content of About the use of select optgroup tag in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn