可选< optgroup>在HTML< select>标签 [英] Selectable <optgroup> in HTML <select> tag

查看:118
本文介绍了可选< optgroup>在HTML< select>标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让选项组可选?

 < select> 
< optgroup value =0label =父标记>
< option value =1>子标签< / option>
< option value =2>子标签< / option>
< / optgroup>
< / select>


解决方案

我不认为你可以,但你可以轻松使用css重现视觉风格,因此只在选择中有选择,所以一切都是可选择的。

.optionGroup {font-weight:bold; font-style:italic;} .optionChild {padding-left:15px;}

 < select multiple =multiple> < option value =0class =optionGroup>父标签< / option> < option value =1class =optionChild> Child Tag< / option> < option value =2class =optionChild>儿童标记< / option>< / select>  

p>

多重属性允许您选择多行(使用Ctrl单击)。如果它不是你想要的,你可以删除它。这是为了告诉你,一切都变得可选,并且看起来与optiongroup元素一样。


Is there any way to make the option group selectable?

<select>
   <optgroup value="0" label="Parent Tag">
      <option value="1">Child Tag</option>
      <option value="2">Child Tag</option>
   </optgroup>
</select>

解决方案

I don't think you can but you can easily reproduce the visual style with css and thus only have options in your select, so everything is selectable.

.optionGroup {
    font-weight: bold;
    font-style: italic;
}
    
.optionChild {
    padding-left: 15px;
}

<select multiple="multiple">
    <option value="0" class="optionGroup">Parent Tag</option>
    <option value="1" class="optionChild">Child Tag</option>
    <option value="2" class="optionChild">Child Tag</option>
</select>

The multiple attribute allow you to select more than one row (with ctrl click). You can remove it if it is not what you want. It was to show you that everything became selectable and that is looking the same as with optiongroup element.

这篇关于可选&lt; optgroup&gt;在HTML&lt; select&gt;标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆