JQ 倒计时

 

html 代码随便定个按钮

50S

JS代码

// 点击开始计时
$("#countdown").click(function(){
    down_time(60);
});

function down_time(time) {
    var btn = $("#countdown");
    btn.css("pointer-events","none");//按钮禁止点击
    btn.css('border','')
    btn.text(time <= 0 ? "刷新" : "" + (time)+"s");
    var hander = setInterval(function() {
        if (time <= 0) {
            clearInterval(hander); //清除倒计时
            btn.text("刷新");
            btn.css('border','1px solid rgb(0, 0, 0)')
            btn.css("pointer-events","initial")
            return false;
        }else {
            btn.text("" + (time--)+"s");
        }
    }, 1000);
}

来个镇贴神兽 

JQ 倒计时_第1张图片

 

 

你可能感兴趣的:(html,js,js,html,jquery)