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)
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)
Share Improve this question edited Oct 12, 2012 at 20:26 atomikpanda asked Oct 12, 2012 at 20:10 atomikpandaatomikpanda 1,8865 gold badges35 silver badges47 bronze badges 2- I can't deduce a specific question here, but for animation, jQuery's various effect calls are good places to start... – blackcatweb Commented Oct 12, 2012 at 20:14
- 1 Could you please check if you put the second or the last one first if it works in firefox? – xception Commented Oct 12, 2012 at 20:26
1 Answer
Reset to default 7You 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);
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745634010a4637277.html
评论列表(0条)