[英]ClearInterval: The function body was executed after the expected time but i can't seem to get it off the screen afterwards
The clearInterval() method is not working after execution of the function body. clearInterval() 方法在函数体执行后不起作用。 here's the code snippet:
这是代码片段:
const clearAll = () =>{
const del = setTimeout(() => Display.textContent = 'deleted',100);
clearTimeout(del)
}
clearBtn.addEventListener("click", clearAll)
It seems you delete the timeout before it happens at least once.似乎您在超时至少发生一次之前删除了它。 Try calling
clearTimeout
after it executes.执行后尝试调用
clearTimeout
。
const clearAll = () => {
const del = setTimeout(() => {
Display.textContent = 'deleted';
clearTimeout(del);
}, 100);
};
clearBtn.addEventListener("click", clearAll);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.