How to check over whether the animation?

Found one way but it's not working
var obj = document.getElementById("ID");

obj.addEventListener("webkitAnimationEnd", EndFunc());
obj.addEventListener("animationend", EndFunc()); 

function EndFunc() {
console.log('ok');
}

maybe someone knows better than me what the problem is or how to solve it?
June 5th 19 at 21:40
2 answers
June 5th 19 at 21:42
Solution
el.addEventListener('animationstart', function(e) { 
 alert('Animation' + e.animationName + 'has started');
});

el.addEventListener('animationend', function(e) { 
 alert('Animation' + e.animationName + 'has ended');
});


Demo
and if the animation is infinite? - osvaldo commented on June 5th 19 at 21:45
,
el.addEventListener('animationiteration', function(e) { 
 // your code
});
- Lenny.Botsfo commented on June 5th 19 at 21:48
June 5th 19 at 21:44
obj.addEventListener("animationend", EndFunc());


brackets after EndFunc superfluous. you are the result of the call to pass and not the function itself

Find more questions by tags JavaScript