如何在客户端发生之前取消/终止window.setTimeout? [英] How to cancel/kill window.setTimeout before it happens on the client?

查看:152
本文介绍了如何在客户端发生之前取消/终止window.setTimeout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个地方,我使用下面的行来清除状态,例如。我有一些停留10秒或更长时间,如果用户点击动作,可能会以不正确的时间间隔发生。有没有可能取消或杀死这个w /一些jQuery或JavaScript所以我没有这个过程闲逛?

I have a few places where I use the line below to clear out a status for example. I have a few of these that hang out for 10 seconds or more and if the user gets clicking around the action can occur at incorrect time intervals. Is it possible to cancel or kill this w/ some jQuery or JavaScript so I don't have this process hanging around?

window.setTimeout(function() { removeStatusIndicator(); }, statusTimeout);


推荐答案

var timer1 = setTimeout(function() { removeStatusIndicator(); }, statusTimeout);

clearTimeout(timer1)

这篇关于如何在客户端发生之前取消/终止window.setTimeout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆