jquery remove class after css animation played?

后端 未结 6 1837
甜味超标
甜味超标 2021-01-04 11:06

I have the css code:

body.start{-webkit-animation:srcb ease-in .4s 1;}

and just play once when entered the website

but the problem

6条回答
  •  渐次进展
    2021-01-04 12:06

    Here is the code:

    var div = document.querySelector('div');
    
    function callback() {
        div.classList.remove('start'); // or modify div.className
    }
    
    div.addEventListener("webkitAnimationEnd", callback, false);
    

    Check this live example on jsbin.

    Please notice, that your animation and my solution work only in webkit-based browsers. In production environment you should take into consideration other browsers and mandatory provide prefix-free solution.

提交回复
热议问题