Reset animation to original position using javascript -


using following script able move picture right when clicked:

<script> var mytimer = null;  function move(){     document.getelementbyid("fish").style.left =          parseint(document.getelementbyid("fish").style.left)+1+'px'; }   window.onload=function(){      document.getelementbyid("fish").onclick=function(){         if(mytimer == null){             mytimer = setinterval("move();", 10);         }else{             clearinterval(mytimer);             mytimer = null;         }     } } </script> 

i having trouble reseting picture original location without using jquery.

if can appreciated.

if capture original position ahead of time can reset later captured value:

var originalposition = document.getelementbyid("fish").style.left;  function resetposition() {     document.getelementbyid("fish").style.left = originalposition; } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -