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.

example here

#ball.animate {     animation:bounce 3s infinite;     -webkit-animation:bounce 3s infinite; } 

jquery:

$('button').on('click',function(){     $('#ball').toggleclass('animate'); }); 

Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -