Stop setInterval call in JavaScript

前端 未结 16 1808
星月不相逢
星月不相逢 2020-11-21 05:00

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?

I want the us

16条回答
  •  一整个雨季
    2020-11-21 05:49

    I guess the following code will help:

    var refreshIntervalId = setInterval(fname, 10000);
    
    clearInterval(refreshIntervalId);
    

    You did the code 100% correct... So... What's the problem? Or it's a tutorial...

提交回复
热议问题