blob: 5af1cdbdd0e95704e2242f8798f6f0066bd87a87 (
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
|
---
title: Animation.id
slug: Web/API/Animation/id
tags:
- 动画
translation_of: Web/API/Animation/id
---
<p>{{ SeeCompatTable() }}{{ APIRef("Web Animations API") }}</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> 的 <code><strong>Animation</strong></code><strong><code>.id </code></strong>属性可返回或设置用于识别某个动画的唯一标识.</p>
<h2 id="获取与设置_animation.id">获取与设置 <code>animation.<em>id</em></code></h2>
<div class="syntaxbox">
<pre class="brush: js">// 获取动画的 id
var animationsId = animation.<em>id</em>;
// 设置动画的 id
animation.<em>id</em> = "newId";
</pre>
</div>
<h2 id="返回值">返回值</h2>
<p>当该动画已被分配 id, 返回一个 {{domxref("DOMString")}}, 当该动画未被分配 id 则返回 null.</p>
<h2 id="示例">示例</h2>
<p>在 <a href="http://codepen.io/rachelnabors/pen/eJyWzm?editors=0010">Follow the White Rabbit example</a> 这个例子里, 你可以像下面的方式一样,为 <code>rabbitDownAnimation</code> 分配一个 id:</p>
<pre class="brush: js">rabbitDownAnimation.effect.<em>id</em> = "rabbitGo";
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">说明</th>
</tr>
<tr>
<td>{{SpecName('Web Animations', '#dom-animation-id', 'Animation.id' )}}</td>
<td>{{Spec2('Web Animations')}}</td>
<td>Editor's draft.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器支持">浏览器支持</h2>
{{Compat("api.Animation.id")}}
<h2 id="相关文档" style="line-height: 30px; font-size: 2.14285714285714rem;">相关文档</h2>
<ul>
<li><a href="/en-US/docs/Web/API/KeyframeEffect">KeyframeEffect Interface</a></li>
<li><a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a></li>
<li>{{domxref("Animation")}}</li>
</ul>
|