datalist

HTML <datalist>元素包含了一组<option>元素,这些元素表示其它表单控件可选值.

属性

该元素除了公用的全局属性之外,没有其他属性。

示例

<label>Choose a browser from this list:
<input list="browsers" name="myBrowser" /></label>
<datalist id="browsers">
  <option value="Chrome">
  <option value="Firefox">
  <option value="Internet Explorer">
  <option value="Opera">
  <option value="Safari">
</datalist>

结果

规范

规范 状态 备注
HTML Living Standard
<datalist>
Living Standard
HTML5
<datalist>
Recommendation

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
datalistChrome Full support 20Edge Full support YesFirefox Full support 4IE Full support 10Opera Full support 9.5Safari Full support 12.1WebView Android Full support 4.4.3Chrome Android Full support 33Firefox Android Full support 4Opera Android Partial support Partial
Notes
Partial support Partial
Notes
Notes The dropdown menu containing available options does not appear in Opera for Android.
Safari iOS Full support 12.2Samsung Internet Android Full support 2.0

Legend

Full support  
Full support
Partial support  
Partial support
See implementation notes.
See implementation notes.

Polyfill

以下Polyfill旨在支持旧的或者目前不兼容的浏览器:datalist-polyfill

参见