Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  146] [ 5]  / answers: 1 / hits: 27570  / 12 Years ago, fri, july 6, 2012, 12:00:00
setInterval(FunctionA(), 1000);


Now how do I clear this interval after exactly 5 seconds so that I can achieve -



var i = setInterval(FunctionA(), 1000);
(After 5 seconds)
clearInterval(i);

More From » setinterval

 Answers
3

You can do this using setTimeout function:



var i = setInterval(FunctionA ,1000);
setTimeout(function( ) { clearInterval( i ); }, 5000);

[#84421] Thursday, July 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidan

Total Points: 72
Total Questions: 95
Total Answers: 121

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
aidan questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Sep 29, 21, 00:00, 3 Years ago
Sun, Sep 5, 21, 00:00, 3 Years ago
Thu, Jan 16, 20, 00:00, 4 Years ago
;