+ 3
Hello everyone!
I would like to know how to repeat animation on event click (jQuery). can anyone help me please thank you! :-)
2 Respuestas
+ 3
<!--
Not using JQuery, but principle is to define animation for a specific class name, and onclick, delete the class name, set minimal timeout (so browser take account of modified class element) after wich set again the class name to the element:
-->
<!DOCTYPE html>
<html>
<head>
<style>
#obj {
position:relative;
width:10vw;
height:10vw;
background:orange;
}
.anim {
animation:anim 3s linear forwards;
}
@keyframes anim {
from { left:0; }
to { left:90vw; }
}
</style>
</head>
<body>
<div id="obj" class="anim" onclick="this.className=''; window.setTimeout(function(self){self.className='anim';},0,this)"></div>
</body>
</html>
+ 2
thank you! that help a lot🙂