프론트앤드 이야기/JavaScript & JQuery

[Javascript] timer 만들기

한희성 2020. 11. 3.
반응형

<span class = "input_code"id = "authTimer"> </ span>


var timer = 1199;

function authTimer () {

var minutes;

var seconds;

var timeCheck = setInterval (function () {

minutes = parseInt (timer / 60,10);

seconds = parseInt (timer % 60,10);

minutes = minutes <10? "0"+ minutes : minutes + "";

seconds = seconds <10? "0"+ seconds : seconds + "";

$ ( "# authTimer"). text (minutes + ":"+ seconds);


if (timer -<1) {

timer  = 0000;

clearInterval (timeCheck );

}

},1000);

}

반응형

댓글

💲 추천 글