倒計時到2秒 就沒了,求解
<!DOCTYPE?html> <html> <head> <meta?charset="UTF-8"> <title></title> <script?type="text/javascript"> window.onload?=?function(){ var?send?=?document.getElementById('send'), times?=?60, timer?=?null; send.onclick?=?function(){ //計時開始 timer?=?setInterval(function(){ send.value?=?times?+?"秒后重試"; send.setAttribute('disabled','disabled'); times--; if(times?<=?0){ send.value?=?"發(fā)送驗(yàn)證碼"; send.removeAttribute('disabled'); clearInterval(timer); times?=?60; } },1000); } } </script> </head> <body> <input?type="button"?id="send"?value="發(fā)送驗(yàn)證碼"/> </body> </html>
沒有1秒后重試,而是直接跳到發(fā)送驗(yàn)證碼,這是什么情況,是哪里有問題呢,求解一下。
2017-06-25
?times--;
if(times < 0){ //你這里出錯了
...