问题
I do with select in two ways:
- With disabled option.
- With optgroup tag.
<select name="curso1" id="curso1">
<option disabled="" style="font-size:12px; text-align:left; font-family:Arial Black">Group</option>
<option value="1">Windows 8</option>
<option value="8">lalalala</option>
</select>
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
How to do this in a datalist?
How do group with the datalist?
回答1:
This looks neat on Chrome, but I don't know how it will render in other browsers.
<label>Choose a browser from this list:
<input list="browsers" name="myBrowser" /></label>
<datalist id="browsers">
<option value="Brave">GroupA</option>
<option value="Firefox"></option>
<option value="Safari"></option>
<option value="Opera">GroupB</option>
<option value="Internet Explorer"></option>
<option value="Microsoft Edge"></option>
</datalist>
来源:https://stackoverflow.com/questions/33310969/input-with-datalist-grouping