Help us test MDN's new front-end:

Document: animationiteration event

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

The animationiteration event is fired when an iteration of a CSS Animation ends, and another one begins. This event does not occur at the same time as the animationend event, and therefore does not occur for animations with an animation-iteration-count of one.

Bubbles Yes
Cancelable No
Interface AnimationEvent
Event handler property onanimationiteration

The original target for this event is the Element that had the animation applied. You can listen for this event on the Window interface to handle it in the capture or bubbling phases. For full details on this event please see the page on HTMLElement: animationiteration.


This code uses animationiteration to keep track of the number of iterations an animation has completed:

let iterationCount = 0;

document.addEventListener('animationiteration', () => {
  console.log(`Animation iteration count: ${iterationCount}`);

The same, but using the onanimationiteration event handler property:

let iterationCount = 0;

document.onanimationiteration = () => {
  console.log(`Animation iteration count: ${iterationCount}`);

See a live example of this event.


Specification Status Comment
CSS Animations Working Draft Initial definition

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
animationiteration eventChrome Full support 43Edge ? Firefox Full support 51IE ? Opera Full support 30Safari ? WebView Android Full support 43Chrome Android Full support 43Edge Mobile ? Firefox Android Full support 51Opera Android Full support 30Safari iOS ? Samsung Internet Android ?


Full support  
Full support
Compatibility unknown  
Compatibility unknown

See also


此页面的贡献者: wbamberg, mdnwebdocs-bot, estelle, mfuji09
最后编辑者: wbamberg,