Topic: Stop jQuery annimation in progress

In playing with jQuery to understand it better in a doing way, I made a project for myself to have a square move from right to left in the browser and then back again.  So far I was able to make a function that does one iteration and another that resets the square but before I try to understand how to keep the loop continuously I was hoping to write code to stops the animation with another click event, but don’t know how to do that.  If you can please point me where to look for clues?
Here is the code I have written so far.

$(document).ready(function(){
                $("#start").click(function(){
                    $("#block").animate({"left": "500px"}, "slow")
                    .animate({"left": "25px"}, "slow")  });

                $("#reset").click(function(){
                    $("#block").css({top:"150px", left:"25px", borderWidth:""});
                });
                
                $("#stop").click(function(){
                    
                });
            });

Vote up Vote down

Re: Stop jQuery annimation in progress

I believe this is what you are looking for...

http://docs.jquery.com/Effects/stop

Benjamin Falk | Falken Creative : Twitter
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter

Vote up Vote down