📅  最后修改于: 2023-12-03 15:15:44.050000             🧑  作者: Mango
HTML
以下是HTML
<select>
<optgroup label="group1">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</optgroup>
<optgroup label="group2">
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
</optgroup>
</select>
<select>
元素为带有选项的下拉菜单创建一个控件。<optgroup>
元素定义组的标签和选项。label
属性指定组的标签。下面是如何使用HTML
<select id="options">
<optgroup label="Fruits">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
</optgroup>
<optgroup label="Vegetables">
<option value="carrot">Carrot</option>
<option value="cucumber">Cucumber</option>
</optgroup>
</select>
HTML