js 实现60秒倒计时

1.dom元素 

剩余时间:60

2.js 代码

var timeClock;
function sendCode() {
    var timer_num = 60;
    timeClock=setInterval(function(){
        timer_num--;
        $('.clock').html(timer_num);
       
        if (timer_num == 0) {
            clearInterval(timeClock);
            $('.clock').html(60);
        } 
    },1000)
 
}
$("button").click(function(){
	sendCode();
})

 

你可能感兴趣的:(js 实现60秒倒计时)