HTML | DOM animationstart Event
The animationstart event occurs when a CSS animation has started to play.
events that can occur when a CSS animation plays:
- animationstart: occurs when the CSS animation has started.
- animationiteration: occurs when the CSS animation is repeated.
- animationend: occurs when the CSS animation has completed.
Syntax:
- Code for Chrome, Safari and Opera:
object.addEventListener("webkitAnimationStart", myScript); - Standard syntax:
object.addEventListener("animationstart", myScript);
Example:
<!DOCTYPE html> <html> <head> <style> #div { width: 100%; height: 100px; background: green; position: relative; font-size: 40px; } /* Chrome, Safari, Opera */ @-webkit-keyframes mymove { from { top: 0px; } to { top: 200px; } } @keyframes mymove { from { top: 0px; } to { top: 200px; } } </style> </head> <body> <center> <h1 style="color:green"> GeeksforGeeks </h1> <div id="div" onclick="GFGFun()"> Click me to start the animation. </div> <script> var x = document.getElementById("div"); // Start the animation with JavaScript function GFGFun() { // Code for Chrome, Safari and Opera x.style.WebkitAnimation = "mymove 4s 1"; // Standard syntax x.style.animation = "mymove 4s 1"; } // Code for Chrome, Safari and Opera x.addEventListener("webkitAnimationStart", StartFun); // Standard syntax x.addEventListener("animationstart", StartFun); function StartFun() { this.innerHTML = "The animation has started"; this.style.backgroundColor = "lime"; } </script> </center> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browsers supported by animationstart Event are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | DOM onclick Event
- HTML | DOM oncopy Event
- HTML | DOM oncut Event
- HTML | DOM onchange Event
- HTML | DOM ontoggle Event
- HTML | DOM oncontextmenu Event
- HTML | DOM ondurationchange Event
- HTML | DOM onstalled Event
- HTML | DOM ondrop Event
- HTML | DOM ondragstart Event
- HTML | DOM ondblclick Event
- HTML | DOM ondragend Event
- HTML | DOM ondragenter Event
- HTML | DOM onmouseleave Event
- HTML | DOM onmousemove Event
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


