이 타이머를 일시 중지하는 방법은 무엇입니까? 다시 일시 중지하고 계속 계산하는 방법이 일시 중지 된 경우 일시 중지 할 때자바 스크립트 타이머 일시 중지
var timeKeeper = setInterval(countdown, 1000);
그런 다음, clearInterval
을 사용합니다 : 그것은
function timer($time) {
let $lorem = $("#lorem");
function countdown() {
let $minutes = Math.floor($time/60);
let $seconds = $time % 60;
let $result = $minutes + ":" + ($seconds < 10 ? "0" + $seconds : $seconds);
--$time;
$lorem.text($result);
}
countdown();
setInterval(countdown, 1000);
}
timer(200);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="lorem"></div>
내 대답이 문제를 해결합니까? 어떤 답변이 당신에게 도움이된다면 (http://meta.stackexchange.com/questions/173399/how-to-upvote-on-stack-overflow), 당신이 찾고있는 답변이 [ 정답] (http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)을 참조하십시오. 고맙습니다! –