How can I start CSS animations with js? the first line (webkitAnimation) works but the other ones don't.
anim_logo.style.webkitAnimation="threesixty 3s";
anim_logo.style.mozAnimation="threesixty 3s";
anim_logo.style.oAnimation="threesixty 3s";
anim_logo.style.animation="threesixty 3s";
why?
live preview (Click on the Ninja Star)
You better make a separate class with that animation and simply attach it to your element when needed:
anim_logo.setAttribute("class", yourAnimationClass);
UPDATE
To remove the newly added class you can use a delayed function:
function animateMe() {
anim_logo.setAttribute( "class", yourAnimationClass );
setTimeout( function() {
anim_logo.setAttribute( "class", "" );
}, 3000);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With