html - Start CSS Animations JavaScript - Stack Overflow

How can I start CSS animations with js?the first line (webkitAnimation) works but the other ones don&#

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
Add a ment  | 

1 Answer 1

Reset to default 7

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);
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745634010a4637277.html

相关推荐

  • html - Start CSS Animations JavaScript - Stack Overflow

    How can I start CSS animations with js?the first line (webkitAnimation) works but the other ones don&#

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信