diff --git a/source/_posts/Timing.md b/source/_posts/Timing.md index 3f6c186..5c173f6 100644 --- a/source/_posts/Timing.md +++ b/source/_posts/Timing.md @@ -65,4 +65,20 @@ function delayedMessage() { function sayHello() { id("output-text").textContent = "你好!"; } +``` + +# setInterval函数例子 +```html + + +``` +```javascript +let timerId = null; //存储interval定时器的ID +function repeatedMessage() { + timerId = setInterval(sayHello, 1000); +} + +function sayHello() { + id("output-text").textContent += "你好!"; +} ``` \ No newline at end of file