How to stop/override a Jquery TimeOut function? How to stop/override a Jquery TimeOut function? jquery jquery

How to stop/override a Jquery TimeOut function?


First, you store the return value for the setTimeout function:

// Set the timeoutvar timeout = setTimeout(function()    {        // Your function here    }, 2000);

Then, when you're ready to kill the timeout...you just call clearTimeout with the stored value from the previous call to setTimeout.

// Then clearn the timeoutclearTimeout(timeout);


You can use .stop()

Stop the currently-running animation on the matched elements.


jQuery 1.4 has a built in method to handle delays for animations you can do something like this:

$("#mini-txt").html("Thank you!");$("#mini").fadeIn("fast").delay(3000).animate({height: "hide", opacity: "hide"}, "medium");

And then later when you want to clean the animation queue you can do:

$("#mini").stop(true);