一只小新
2020-05-14 17:46
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>验证码按钮倒计时</title>
</head>
<body>
<input type="button" id='send' value="发送验证码">
</body>
<script type="text/javascript">
var send = document.getElementById('send');
times = 10;
timer = null;
// console.log(send.value);
if (send.value = '发送验证码') {
send.onclick = function () {
var tant = this;
// if (timer) {
// clearInterval(timer);
// timer = null;
// }
timer = setInterval(function () {
times--;
if (times <= 0) {
tant.setAttribute('value', '发送验证码');
tant.disabled="";
clearInterval(timer);
times = 10;
} else {
tant.setAttribute('value', times + '秒后重试');
}
console.log(times);
}, 1000);
tant.setAttribute('disabled','true');
}
}
</script>
</html>
不错 ,有想像
很好很用心了,不错
Tab选项卡切换效果
65469 学习 · 533 问题
相似问题