标签:clear led jquery disable add set console rem query
function get_countdown(elementName) {
var t = 59;//倒计总秒数
var time = 59;//当前秒数
if (time == t) { //如果不加入该判断,则会出现在倒计时期间不断的点击发生不断的加快(其实就是你点了多少次就重复多少次该函数)的问题,用setTimeout()方法不加此判断也是一样的
var time1 = setInterval(function() {
if (time == 0) {
$(elementName).html("Resend");
$(elementName).removeAttr("disabled");
time = t;
clearInterval(time1);
$(elementName).addClass("bg-color4").removeClass("bg-color3");
} else {
$(elementName).attr("disabled","true");
$(elementName).html(time + "s Resend");
$(elementName).removeClass("bg-color4").addClass("bg-color3");
time--;
}
console.log(time);
}, 1000);
}
}
标签:clear led jquery disable add set console rem query
原文地址:https://www.cnblogs.com/pangchunyu/p/12208522.html