1,利用settimeout,语法:
setTimeout(/*执行代码*/, /*毫秒*/);每过多少毫秒执行一次代码
每个手机号每日最多发送6次$("#sms").click(function() { setTimer();});var wait = 60; function setTimer() { if (wait == 0) { $("#sms").attr("disabled", false); // btn.text = ""; $("#sms").text("免费获取验证码"); wait = 60; } else { $("#sms").attr("disabled", true); // btn.text = wait + "秒后重新获取验证码"; $("#sms").text(wait + "秒后重新获取验证码"); wait--; setTimeout(function() { setTimer(); }, 1000) } }
2.
var t1=window.setInterval(hello,1000);
window.clearInterval(t1);//去掉定时器
//待续