JavaScript AnimationEvent elapsedTime Property
You are Here:
JavaScript AnimationEvent elapsedTime Property
The event.elapsedTime
property returns the number of seconds an animation has been running, when an animation event occurs.
Note: This property is read-only.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<head>
<style>
h2{
color: blue;
-webkit-animation: myMultiColor 2s infinite;
animation: myMultiColor 2s infinite;
}
/* Safari 4.0 - 8.0 */
@-webkit-keyframes myMultiColor{
from {color: blue;}
to {color: green;}
}
/* Standard syntax */
@keyframes myMultiColor{
from {color: blue;}
to {color: green;}
}
</style>
</head>
<body>
<h2 onanimationiteration="myFunction(event)">Animation is Awesome</h2>
<p id="point"></p>
<script>
function myFunction(e){
var txt = "Elapsed Time: "+e.elapsedTime+" seconds";
document.getElementById("point").innerHTML = txt;
}
</script>
</body>
</html>
Syntax
event.elapsedTime
Return Values
Value | Explanation |
---|---|
Number | Returns a number representing the number of seconds an animation has been running. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.