jQuery选择隐藏了空的optgroup

时间:2018-11-14 16:43:37

标签: html css jquery-chosen

我有一个多选择列表,默认情况下,第一个optgroup为空(没有子选项),默认情况下它会隐藏该组,但我仍然想显示它。有没有一种方法可以强制选择不隐藏它?参考图像,我们可以看到标签Main的选项组不在列表中。

This is how chosen select list looks like

$('.chosen-control').chosen({ width: 400 });
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.js"></script>

</head>
<body>
    <select multiple class="chosen-control">
            <optgroup label="Main"></optgroup>
            <optgroup label="Group A">
                <option>Option A1</option>
                <option>Option A2</option>
                <option>Option A3</option>
            </optgroup>
            <optgroup label="Group B">
                <option>Option B1</option>
                <option>Option B2</option>
                <option>Option B3</option>
            </optgroup>
            <optgroup label="Group C">
                <option>Option C1</option>
                <option>Option C2</option>
            </optgroup>
    </select>
</body>
</html>

0 个答案:

没有答案