How to reset timeout in Javascript/jQuery?

吃可爱长大的小学妹 提交于 2019-11-29 03:41:04

A timer can be cancelled with clearTimeout, so:

var timer = null;
if (timer) {
    clearTimeout(timer); //cancel the previous timer.
    timer = null;
}
timer = setTimeout(thisFunction, 10000);
var update;

// something happened

clearTimeout(update);
update = setTimeout(thisFunction, 10000);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!