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
Post a Comment