动画:id 属性

Baseline 已广泛支持

此功能已经成熟,并可在许多设备和浏览器版本上使用。自 ⁨2020 年 3 月⁩起,它已在各浏览器中推出。

Web Animations API 的 Animation.id 属性返回或设置用于标识动画的字符串。

一个可用于标识动画的字符串,如果动画没有 id,则为 null

示例

在红心王后的赛跑游戏示例中,您可以像这样为 redQueenAlice 分配一个 id

js
redQueenAlice.id = "redQueenAlice";

规范

规范
Web 动画
# dom-animation-id

浏览器兼容性

另见