
实现代码:
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><script type="text/javascript">window.onload=function(){var send=document.getElementById("send"),times=60,timer=null;send.onclick=function(){ // 计时开始 var that = this;this.disabled=true;timer = setInterval(function(){times --;that.value = times + "秒后重试";if(times <= 0){that.disabled =false;that.value = "发送验证码";clearInterval(timer);times = 60;}//console.log(times);},1000);}} </script></head><body><input type="button" id="send" value="发送验证码"></body></html>注意点: