animationiteration Event
Example
After the CSS animation replays, for the
var x = document.getElementById("myDIV");
// Chrome, Safari and Opera code
x.addEventListener("webkitAnimationIteration", myStartFunction);
// Standard syntax
x.addEventListener("animationiteration", myStartFunction);
Try it »
Definition and Usage
The animationiteration event is triggered when the CSS animation replays.
If the CSS animation-iteration-count attribute is set to "1", the animation will play only once, and the animationiteration event will no longer be triggered.
For more about CSS animations, please see our CSS3 Animations section.
When a CSS animation plays, the following three events occur:
- animationstart - Triggered when the CSS animation starts
- animationiteration - Triggered when the CSS animation repeats
- animationend - Triggered when the CSS animation completes
Browser support
The numbers in the table indicate the version number of the first browser to support the event.
The number specified after "webkit" or "moz" is the prefix of the first version to support the event.
| Events | |||||
|---|---|---|---|---|---|
| animationiteration | 4.0 webkit | 10.0 | 16.0 | ||
| 5.0 moz | 4.0 webkit | 15.0 webkit | |||
| 12.1 |
Note: The Chrome, Safari and Opera browsers use the webkitAnimationEnd prefix.
Syntax
object.addEventListener("webkitAnimationIteration",
myScript
); // Chrome, Safari and Opera code
object
.addEventListener("animationiteration",
myScript
); // Standard syntax
Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() method.
Technical Details
| Does it support bubbling: | Yes |
|---|---|
| Is it cancelable: | No |
| Event type: | AnimationEvent |
Related pages
CSS Tutorial: CSS3 Animations
CSS Reference Manual: CSS3 Animation Properties
CSS Reference Manual: CSS3 animation-iteration-count Property
HTML DOM Reference Manual: Style Animation Properties
Event Object