当何取消setTimeout()?

伟大de虫子 2004-04-29 09:58:21

当我setTimeout("myFunc()",1000);了后,将会在1秒后执行myFunc()函数,

但我想在时间还没到的时候若果触发了函数myDelay(),则取消这个定时运行的设置(或者延时),如何才能做得到?

谢谢!
...全文
988 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
kisslan 2004-04-29
  • 打赏
  • 举报
回复
var time = setTimeout("myFunc()",1000);

clearTimeout(time);
gaofaq 2004-04-29
  • 打赏
  • 举报
回复
clearTimeout Method

--------------------------------------------------------------------------------

Cancels a time-out that was set with the setTimeout method.

Syntax

window.clearTimeout(iTimeoutID)

Parameters

iTimeoutID Required. Integer that specifies the time-out setting returned by a previous call to the setTimeout method.

Return Value

No return value.

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧