Input with datalist grouping

青春壹個敷衍的年華 提交于 2020-12-08 05:57:51

问题


I do with select in two ways:

  1. With disabled option.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!