按鈕
<button class="button">獲取驗(yàn)證碼</button>
jquery
$('.button').click(function() {
let count = 60;
const countDown = setInterval(() => {
if (count === 0) {
$('.button').text('重新發(fā)送').removeAttr('disabled');
$('.button').css({
background: '#ff9400',
color: '#fff',
});
clearInterval(countDown);
} else {
$('.button').attr('disabled', true);
$('.button').css({
background: '#d8d8d8',
color: '#707070',
});
$('.button').text(count + '秒后獲取');
}
count--;
}, 1000);
});