JavaScript获取短信验证码(周期性)
时间:2020-12-15 01:54:50|栏目:JavaScript代码|点击: 次
本文实例为大家分享了js周期性获取短信验证码的具体代码,供大家参考,具体内容如下
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <input type="text"/> <input type="button" id="btn" value="点击发送验证码"/> <script> var timerId = null; var btn = document.getElementById("btn"); var num = 5; btn.onclick = function () { btn.disabled = true; timerId = setInterval(function () { num--; btn.value = num + "秒后可以发送"; if (num === 0) { clearInterval(timerId); btn.value = "点击发送验证码"; btn.disabled = false; num = 5; } }, 1000); }; </script> </body> </html>
栏 目:JavaScript代码
本文地址:http://www.codeinn.net/misctech/33100.html