且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带输入字段的HTML选择下拉菜单

更新时间:2023-08-17 18:01:52

您可以将输入文本与list属性一起使用,它指的是

You can use input text with "list" attribute, which refers to the datalist of values.

<input type="text" name="city" list="cityname">
<datalist id="cityname">
  <option value="Boston">
  <option value="Cambridge">
</datalist>

这将创建一个***文本输入字段,该字段还具有用于选择预定义选项的下拉列表。例如归属地和更多信息: https://www.w3.org/wiki/HTML/Elements/datalist

This creates a free text input field that also has a drop-down to select predefined choices. Attribution for example and more information: https://www.w3.org/wiki/HTML/Elements/datalist