// 恢复初始状态
const init = (countTime) => {
window.holdTime = 3;
window.btn = e('#btn');
$(btn).removeAttr('disabled');
btn.innerText = '可以点击';
clearInterval(countTime);
};
// 读秒计时间
const counting = () => {
let countTime = setInterval(() => {
holdTime--;
btn.innerText = holdTime + '秒后才能再次点击';
if (holdTime == 0) {
init(countTime);
}
}, 1000);
};
const __main = () => {
init();
bindEvent(btn, 'click', (e) => {
btn.innerText = holdTime + '秒后才能再次点击';
$(btn).attr('disabled', true);
counting();
});
};
__main();
网友评论