var $getCode = $(".resend-btn");
var wait = 60;
function time(btn) {
if (wait === 0) {
btn.removeAttr("disabled");
btn.html("重新发送");
wait = 60;
} else {
btn.attr("disabled", true);
btn.html(wait + "秒后才能再次发送");
wait--;
setTimeout(function () {
time(btn);
}, 1000);
}
}
$getCode.on("click", function () {
time($(this));
var wait = 60;
function time(btn) {
if (wait === 0) {
btn.removeAttr("disabled");
btn.html("重新发送");
wait = 60;
} else {
btn.attr("disabled", true);
btn.html(wait + "秒后才能再次发送");
wait--;
setTimeout(function () {
time(btn);
}, 1000);
}
}
$getCode.on("click", function () {
time($(this));
});
resend-btn为点击触发的class属性。