jQuery stop entire function and fire another -
first function running in loop
function first() { alert("first"); } function defaultanimation() { (function(){ settimeout(function() { first(); }, 5000); settimeout(arguments.callee,5000); })(); second function same slight change
function second() { alert("second"); } function defaultanimation() { (function(){ settimeout(function() { second(); },500); settimeout(arguments.callee,500); })(); what want when click div
$("#div").click(function(){}); then first function stops , second 1 replaces , starts.
use (the key here cleartimeout ):
var myvar; function myfunction() { myvar = settimeout(function(){ alert("hello"); }, 3000); } function mystopfunction() { cleartimeout(myvar); }
Comments
Post a Comment