点击按钮实现倒计时
点击按钮实现倒计时
<body>
<input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" />
<script type="text/javascript">
var countdown=10;
function settime(val) {
if (countdown == 0) {
val.removeAttribute("disabled");
val.value="免费获取验证码";
countdown = 10;
if(countdown==10){
return;
}
} else {
val.setAttribute("disabled", true);
val.value="重新发送(" + countdown + ")";
countdown--;
}
setTimeout(function() {
settime(val)},1000)
}
</script>
</body>
---------------------
作者:u013457570
来源:CSDN
原文:https://blog.csdn.net/u013457570/article/details/52711082
版权声明:本文为博主原创文章,转载请附上博文链接!