The animationiteration event fires when one CSS Animation loop ends and the next begins. Learn addEventListener vs onanimationiteration, how to count loops, why single-iteration animations never fire it, and how it fits next to animationend—with five examples and try-it labs.
01
Kind
Instance event
02
Type
AnimationEvent
03
When
Loop boundary
04
Handler
onanimationiteration
05
Needs
count > 1
06
Status
Baseline widely available
Fundamentals
Introduction
CSS animations can repeat with animation-iteration-count. Each time one loop finishes and the next starts, the browser fires animationiteration. That is perfect for counters, progress labels, or syncing side effects per loop.
MDN: this event does not occur at the same time as animationend, and therefore does not occur for animations with an animation-iteration-count of 1.
💡
Beginner tip
Prefer addEventListener("animationiteration", ...) so you can attach multiple handlers and remove them cleanly. Use a counter variable if you need “how many loops so far.”
Concept
Understanding animationiteration
An instance event on elements whose CSS Animation repeats. It answers: “Did another loop just begin after the previous one ended?”
Fires between iterations (end of one loop → start of the next).
Does not fire for animation-iteration-count: 1.
Does not replaceanimationend on the final loop.
AnimationEvent — includes animationName, elapsedTime, pseudoElement.
Baseline Widely available on MDN (since December 2019).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
animationiteration is marked Baseline Widely available on MDN (since December 2019). Logos use the shared browser-image-sprite.png sprite from this project. Pair it with animationend for complete loop handling.
✓ Baseline · Widely available
Element animationiteration
Works across modern desktop and mobile browsers for multi-iteration CSS animations.
100%Widely available
Google ChromeSupported · Desktop & Android
Full support
Mozilla FirefoxSupported · Desktop & Android
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaSupported · Modern versions
Full support
Internet ExplorerLegacy support with prefixes in older IE
Partial
animationiterationBaseline
Bottom line: Use when animation-iteration-count is greater than one (or infinite). One-shot animations will not fire this event.
Wrap Up
Conclusion
animationiteration is the loop-boundary signal for repeating CSS Animations. Count iterations with a simple variable, remember single-cycle animations skip this event, and finish cleanup on animationend.
Set animation-iteration-count to 2+ when you need this event
Keep your own counter for “loops completed”
Also listen for animationend for final cleanup
Filter with event.animationName when multiple animations share a node
❌ Don’t
Expect the event from animation-iteration-count: 1
Confuse it with animationend on the last loop
Assume it fires together with animationend
Forget infinite animations never reach animationend
Overwrite onanimationiteration if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about animationiteration
A loop just finished—and another one is starting.
5
Core concepts
🔄01
Loop boundary
between cycles
Event
🎬02
AnimationEvent
name + time
API
🚫03
count: 1
never fires
Rule
📈04
Count loops
own counter
Pattern
🎯05
Baseline
widely available
Compat
❓ Frequently Asked Questions
It fires when one iteration of a CSS Animation ends and another iteration begins. It does not fire at the same time as animationend, and it does not fire for animations whose animation-iteration-count is one.
No. MDN marks Element animationiteration as Baseline Widely available (since December 2019). It is not Deprecated, Experimental, or Non-standard.
An AnimationEvent. Useful read-only properties include animationName, elapsedTime, and pseudoElement.
Use element.addEventListener("animationiteration", handler) or set element.onanimationiteration = handler. Prefer addEventListener when you need multiple handlers or easy removal.
Because there is no "next" iteration after the only cycle. With animation-iteration-count: 1, you get animationstart and then animationend — no animationiteration in between.
animationiteration marks the boundary between loops while the animation continues. animationend fires once when the entire animation (including the last iteration) has finished.
Did you know?
For an animation with animation-iteration-count: n (where n is a finite integer greater than 1), you typically get n - 1animationiteration events, then one animationend.