-
-
Save anonymous/dd6ce363a55ffc7b4824 to your computer and use it in GitHub Desktop.
setTimeout Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//設定Timeout,預設只會執行一次,毫秒為單位 | |
setTimeout(function() {myFunc();}, 4000) | |
//重覆執行setTimeout | |
function myFunc() {setTimeout(function() {myFunc();}, 4000)} | |
//取消setTimeout | |
var timerID = setTimeout(function() {myFunc();}, 4000) | |
clearTimeout(timerID); | |
//設定條件停止 | |
function myFunc() { | |
if (flag == true) { | |
setTimeout(function() {myFunc();}, 4000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment