html - Start CSS3 animation with jquery -
i trying start specific css animation jquery when click button. no idea how. ideas?
thanks
<button>click here start animation!!</button> <div id="ball"></div> #ball { background:tomato; height:50px; width:50px; border-radius:200px; position:absolute; animation:bounce 3s infinite; -webkit-animation:bounce 3s infinite; top:40px; } @-webkit-keyframes bounce { 50% { top: calc(100% - 50px); } } @keyframes bounce { 50% { top: calc(100% - 50px); } }
a simple method have css animation properties on seperate class , toggle class when button clicked.
#ball.animate { animation:bounce 3s infinite; -webkit-animation:bounce 3s infinite; }
jquery:
$('button').on('click',function(){ $('#ball').toggleclass('animate'); });
Comments
Post a Comment