Sunday 15 April 2012

jquery - How can I Stop count down function then running -



jquery - How can I Stop count down function then running -

i have countdown function, if want stop function while in running mode, how can that?

function gamecounter(){ var sec = 6 $("#gamecounter span").html(sec) var timer = setinterval(function() { $('#gamecounter span').text(sec--); if (sec == -1) { newcards(); clearinterval(timer); } }, 1000); }

one way of doing be,

function gamecounter(){ var sec = 6 $("#gamecounter span").html(sec) var timer = setinterval(function() { $('#gamecounter span').text(sec--); if (sec == -1) { newcards(); clearinterval(timer); } }, 1000); homecoming timer; } //in place calling gamecounter() function. var timer = gamecounter(); //call below line stop interval @ point of time. clearinterval(timer);

jquery

No comments:

Post a Comment