Jump to content
Killersites Forums

Stop jQuery annimation in progress


Recommended Posts

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(){

               });
           });

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...