Skip to content

Instantly share code, notes, and snippets.

@thirdj
Created April 12, 2013 02:01
Show Gist options
  • Select an option

  • Save thirdj/5368715 to your computer and use it in GitHub Desktop.

Select an option

Save thirdj/5368715 to your computer and use it in GitHub Desktop.
time method
setTimeout(); // 일정 시간 후에 함수를 한 번 실행
setInterval(); // 일정 시간마다 함수를 반복 실행
clearTimeout(); // 일정 시간 후에 함수를 한 번 실행하는 것을 중지
clearInterval(); // 일정 시간마다 함수를 반복하는 것을 중지
/*
Eaxmple
**/
window.onload = function(){
// 윈도우가 로드될 때
var intervalID = setInterval(function(){
document.body.innerHTML += '<p>' + new Date() + '</p>';
}, 1000);
// 10초 후 함수를 실행합니다.
setTimeout(function() {
// 타이머를 종료합니다.
clearInterval(intervalID);
}, 10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment