<body>
<input type="text" placeholder="请填写验证码"><button>获取验证码</button>
//HTML部分
</body>、
//JS部分
<script>
var btn = document.querySelector('button')
var num = 60;
btn.onclick = function() {
var that = this
var timer = setInterval(function() {
num--
console.log(num);
if (num <= 0) {
that.innerHTML = '重新获取'
clearInterval(timer)
that.disabled = false
console.log(num);
} else {
that.innerHTML = '请在' + num + 's后再获取'
console.log(num);
that.disabled = true
}
}, 1000)
}
JS动画之短信验证码
最新推荐文章于 2024-08-22 14:32:34 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)