Web/Javascript

javascript 타이머

tealight 2018. 5. 9. 14:30

특정 시간(cycleSecond ) 마다 반복 실행



var cycleSecond = 5; // 주기 (초)


setInterval(function() {

           event(); //이벤트

 },cycleSecond*1000);





특정 시간(cycleSecond ) 이후 이벤트 발생

function timer_event(){

     event(); //이벤트

}


setTimeout(timer_event(), cycleSecond*1000);