<html> <header></header> <script> var wait=60; var interValObj; function fsend(){ interValObj = window.setInterval(setRemainTime, 1000); ///--启动计时器,1秒执行一次 document.getElementById("code_button").disabled=true; document.getElementById("code_button").innerText="倒计时 " + wait + " 秒"; } function setRemainTime() { if (wait == 0) { window.clearInterval(interValObj); //停止计时器 document.getElementById("code_button").disabled=false; document.getElementById("code_button").innerText="重新发送验证码" ; document.getElementById('code_value').value = ''; //清除验证码。如果不清除,过时间后,输入收到的验证码依然有效 wait = 60; } else { wait--; document.getElementById("code_button").innerText="倒计时 " + wait + " 秒"; } } </script> <body> Send Scode <input type="text" id="code_value"/> <button type="button" id="code_button" name="send" onclick="fsend()" >发送验证码</button> </body> </html>