cleartimeout
<html>
<head>
<script type="text/javascript">
let c=0
let t
timedCount=()=>
{
document.getelementbyid('txt').value=c
c=c+1
t=settimeout(timedCount(),1000)
}
stopCount=()=>
{
clearTimeout(t)
}
</script>
</head>
<body>
<form>
<input type="button" value="开始计时!" onClick="timedCount()">
<input type="text" id="txt">
<input type="button" value="停止计时!" onClick="stopCount()">
</form>
</body>
</html>
let timer=null
timeOut = () => {
timer = setTimeout(() => {
console.log('执行')
this.timeOut()
}, 5 * 60 * 1000)
}
// 卸载定时器
clearTimeout(timer)
相关阅读
在javascript中 setInterval()、clearInterval()、cle
setInterval()是一种定时器,它按照指定的设置时间(以毫秒计)来调用函数的方法。clearInterval()是结束定时器的循环调用函数。除非调