blob: 81f2debb2deda5a1ed651d5c94e302d47dff5f4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
---
title: datalist
slug: Web/HTML/Element/datalist
tags:
- Element
- HTML
translation_of: Web/HTML/Element/datalist
---
<p id="概述"><strong><em>HTML </em><code><datalist></code><em>元素</em></strong>包含了一组{{HTMLElement("option")}}元素,这些元素表示其它表单控件可选值.</p>
<p>{{EmbedInteractiveExample("pages/tabbed/datalist.html", "tabbed-standard")}}</p>
<ul class="htmlelt">
<li><dfn><a href="https://developer.mozilla.org/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">内容范畴</a></dfn><a href="https://developer.mozilla.org/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content categories#Flow content">流内容</a>,<a href="https://developer.mozilla.org/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content categories#Phrasing content">段落内容</a>。</li>
<li><dfn>允许内容</dfn>要么 <a href="https://developer.mozilla.org/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Phrasing_content">段落内容</a> 要么 0个或多个 {{HTMLElement("option")}}元素.</li>
<li><dfn>遗漏标签</dfn>{{no_tag_omission}}</li>
<li><dfn>允许父级元素</dfn>任何接受<a href="https://developer.mozilla.org/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Phrasing_content">段落内容</a>的元素.</li>
<li><dfn>Permitted ARIA roles</dfn>None</li>
<li><dfn>DOM接口</dfn>{{domxref("HTMLDataListElement")}}</li>
</ul>
<h2 id="属性">属性</h2>
<p>该元素除了公用的<a href="/zh-CN/docs/Web/HTML/Global_attributes" title="zh-CN/docs/Web/HTML/Global attributes">全局属性</a>之外,没有其他属性。</p>
<h2 id="示例">示例</h2>
<pre class="brush: html"><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></pre>
<h3 id="结果">结果</h3>
<p>{{EmbedLiveSample("示例")}}</p>
<h2 id="Specifications" name="Specifications">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', 'the-button-element.html#the-datalist-element', '<datalist>')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', 'the-datalist-element.html#the-datalist-element', '<datalist>')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("html.elements.datalist")}}</p>
<h2 id="Polyfill">Polyfill</h2>
<p>以下Polyfill旨在支持旧的或者目前不兼容的浏览器:<a href="https://github.com/mfranzke/datalist-polyfill">datalist-polyfill</a></p>
<h2 id="参见">参见</h2>
<ul>
<li class="last">{{ HTMLElement("input") }} 元素,它更特殊的 {{ htmlattrxref("list", "input") }} 属性;</li>
<li class="last"> {{ HTMLElement("option") }}元素.</li>
</ul>
|