WindowOrWorkerGlobalScope
mixin 的 clearInterval()
方法可取消先前通过 setInterval()
设置的重复定时任务。
语法
scope.clearInterval(intervalID)
Parameters
intervalID
- 要取消的定时器的 ID。是由
setInterval()
返回的。
值得一提的是,setInterval()
和 setTimeout()
共用其定义的 IDs,即可以使用 clearInterval()
和 clearTimeout()
中的任意一个。然而,为了使代码可读性更强,你应该尽量避免这种用法。
返回值
示例
规范
规范 | 状态 | 备注 |
---|---|---|
HTML Living Standard WindowOrWorkerGlobalScope.clearInterval() |
Living Standard | Method moved to the WindowOrWorkerGlobalScope mixin in the latest spec. |
HTML Living Standard clearInterval() |
Living Standard |
浏览器兼容性
BCD tables only load in the browser