0

I took this code from another question "CSS Animation onClick". I was wondering if it could be possible to have a button that recall the function, even in the middle of the animation, so that it starts again every time I click on the button. No JQUERY please, thank you!

     <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <style type="text/css">
      .classname {
       -webkit-animation-name: cssAnimation;
       -webkit-animation-duration:3s;
       -webkit-animation-iteration-count: 1;
      -webkit-animation-timing-function: ease;
       -webkit-animation-fill-mode: forwards;
         }
         @-webkit-keyframes cssAnimation {
         from {
          -webkit-transform: rotate(0deg) scale(1) skew(0deg) 
        translate(100px);
            }
            to {
               -webkit-transform: rotate(0deg) scale(2) skew(0deg) 
           translate(100px);
       }
       }
      </style>
       <script type="text/javascript">
        function ani(){
           document.getElementById('img').className ='classname';
          }
          </script>
        <title>Untitled Document</title>
          </head>

      <body>
        <input name="" type="button" onclick="ani()" />
       <img id="img" src="clogo.png" width="328" height="328" />
        </body>
        </html>
dsdsd
  • 1
  • 1

1 Answers1

-2

you could try removing the class and adding it again:

function ani() {
    document.getElementById('img').className = '';
    document.getElementById('img').className = 'classname';
}
Levi Rocha
  • 88
  • 3