【发布时间】:2022-04-12 02:11:11
【问题描述】:
我正在尝试使用 setTimeout,但它不起作用。任何帮助表示赞赏。
有人知道如何解决这个问题吗?
var button = document.getElementById("reactionTester");
var start = document.getElementById("start");
function init() {
var startInterval/*in milliseconds*/ = 1000;
setTimeout(startTimer(), startInterval);
}
function startTimer() {
document.write("hey");
}
【问题讨论】:
-
Learn how to debug JavaScript。您正试图在 DOM 元素存在之前对其进行访问。请参阅Why does jQuery or a DOM method such as
getElementByIdnot find the element?。请解释究竟是什么不起作用。
标签: javascript