jQuery實現發送短信驗證碼后60秒倒計時
<!DOCTYPE html> <html> <head> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> var countdown=60; function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled");
obj.value="免費獲取驗證碼"; countdown = 60; return; } else { obj.setAttribute("disabled", true); obj.value="重新發送(" + countdown + ")"; countdown--; } setTimeout(function() { settime(obj) } ,1000) }</script> <body> <input type="button" id="btn" value="免費獲取驗證碼" onclick="settime(this)" />
</body> </html>
</pre>
本文由用戶 yefx 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!