I am using setInterval(fname, 10000); to call a function every 10 seconds in JavaScript. Is it possible to stop calling it on some event?
setInterval(fname, 10000);
I want the us
setInterval() returns an interval ID, which you can pass to clearInterval():
setInterval()
clearInterval()
var refreshIntervalId = setInterval(fname, 10000); /* later */ clearInterval(refreshIntervalId);
See the docs for setInterval() and clearInterval().