js自动倒计时代码,倒计时完毕时自动停止循环
const getCodeBtn =。。。; let countdown = 60; let intervalId; getCodeBtn.attr("disabled","disabled"); intervalId = setInterval(function () { if (countdown === 0) { getCodeBtn.text("获取验证码"); getCodeBtn.removeAttr("disabled"); clearInterval(intervalId); } else { countdown--; getCodeBtn.text(countdown); getCodeBtn.disabled = true; } }, 1000);
微信号:jamesworkshop 学习QQ群:364976091