Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2012 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dd6ce363a55ffc7b4824 to your computer and use it in GitHub Desktop.
Save anonymous/dd6ce363a55ffc7b4824 to your computer and use it in GitHub Desktop.
setTimeout Example
//設定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