blob: dda8df24272b74e67c147b2a5fbcfcd6abea96d5 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
---
title: draggable
slug: Web/HTML/Global_attributes/draggable
tags:
- 拖动
translation_of: Web/HTML/Global_attributes/draggable
---
<p class="note">{{HTMLSidebar("Global_attributes")}}{{SeeCompatTable}}</p>
<p><a href="/zh-CN/docs/Web/HTML/Global_attributes" style="text-decoration: underline;">全局属性</a> <strong>draggable</strong> 是一个枚举类型的属性,用于标识元素是否允许使用 <a href="/zh-CN/docs/DragDrop/Drag_and_Drop" title="https://developer.mozilla.org/En/DragDrop/Drag_and_Drop">拖放操作 API</a> 拖动。它的取值如下:</p>
<ul>
<li><span style="font-family: Courier New;">true,表示元素可以被拖动</span></li>
<li><span style="font-family: Courier New;">false,表示元素不可以被拖动</span></li>
</ul>
<p>如果该属性没有设值,则默认值 为 <span style="font-family: Courier New;">auto ,表示使用浏览器定义的默认行为。</span></p>
<p>这个属性是<em>枚举类型</em>,而不是 <em>布尔类型</em> 。这意味着必须显式指定值为 <span style="font-family: Courier New;">true</span> 或者 <span style="font-family: Courier New;">false</span> ,像 <code><label draggable>Example Label</label> 这样的简写是不允许的。正确的用法是</code> <code><label draggable="true">Example Label</label>。</code></p>
<p>默认情况下,只有已选中的文本、图片、链接可以拖动。对其它的元素来说,必须按拖动机制的顺序设置 <strong>ondragstart</strong> 事件才能正常工作, 见 <a href="/zh-CN/docs/DragDrop/Drag_Operations" title="https://developer.mozilla.org/En/DragDrop/Drag_Operations">综合示例</a> 。</p>
<h2 id="标准">标准</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG', "interaction.html#the-draggable-attribute", "draggable")}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>No change from latest snapshot, {{SpecName('HTML5.1')}}</td>
</tr>
<tr>
<td>{{SpecName('HTML5.1', "editing.html#the-draggable-attribute", "draggable")}}</td>
<td>{{Spec2('HTML5.1')}}</td>
<td>Snapshot of {{SpecName('HTML WHATWG')}}, initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatGeckoDesktop("1.8.1") }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatGeckoMobile("1.8.1") }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<h2 id="参考资料">参考资料</h2>
<ul>
<li>All <a href="/en-US/docs/Web/HTML/Global_attributes">global attributes</a>.</li>
</ul>
|