setInterval()

https://www.w3schools.com/jsref/met_win_setinterval.asp

 

Window setInterval() Method

Window setInterval() Method ❮ Window Object Example Alert "Hello" every 3 seconds (3000 milliseconds): setInterval(function(){ alert("Hello"); }, 3000); Try it Yourself » More "Try it Yourself" examples below. Definition and Usage The setInterval() method

www.w3schools.com

setInterval(함수, 반복시간);

 

setInterval(function(){ alert("Hello"); }, 1000);

 

// Hello라는 alert창을 1초간격으로 출력

 

setTimeout()

https://www.w3schools.com/jsref/met_win_settimeout.asp

 

Window setTimeout() Method

Window setTimeout() Method ❮ Window Object Example Display an alert box after 3 seconds (3000 milliseconds): setTimeout(function(){ alert("Hello"); }, 3000); Try it Yourself » More "Try it Yourself" examples below. Definition and Usage The setTimeout() met

www.w3schools.com

setTimeout(함수, 지연시간);

 

setTimeout(function(){ alert("Hello"); }, 1000);

 

// Hello라는 alert창을 1초뒤에 출력

 

아래는 clearInterval을 이용한 타이머

 

HTML
Script

'JavaScript > Vanilla JS' 카테고리의 다른 글

document.title  (0) 2020.02.04
Array.map()  (0) 2019.07.31
String 이어붙이기  (0) 2017.09.29
산술연산자 & 관계연산자  (0) 2017.09.29
자료형(2)  (0) 2017.09.29