ClearTimeout within it's own function while running - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:animate

Description

ClearTimeout within it's own function while running

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> 
 </head> /*from  w w  w .  j  av  a 2s.  c  o m*/
 <body> 
  <h1>CATCH ME</h1> 
  <script>
jQuery(function($) { 
    var my = [300,0];
    (function myLoop() {
         $('h1').animate({marginLeft: my.reverse()[1]}, 4000, myLoop);
    })();
    $('h1').click(function(){
       $(this).stop();
    });
});

      </script>  
 </body>
</html>

Related Tutorials