下面是JS代碼:
var timer = 60;
var t = null;
var sent = document.querySelector('.sent');
sent.addEventListener('click', function () {
sent.disable = true;
clearInterval(t);
t = setInterval(function () {
if (timer == 0) {
clearInterval(t);
sent.disable = false;
sent.innerHTML = '發送驗證碼';
timer = 60;
} else {
sent.innerHTML = '還剩下' + timer + '秒';
timer--;
}
}, 1000);
})
這個是按鈕:
<button class="sent">發送驗證碼</button>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/183528.html
標籤:JavaScript
