短信验证码60秒倒计时
html:
<input type="button" class="validCode" value="获取验证码" />
js:
var validCode=true; $(".validCode").click (function () { var time=60; var $code=$(this); if (validCode) { validCode=false; console.log('验证码已发出'); var t=setInterval(function () { time--; $code.val(time+"秒"); if (time==0) { clearInterval(t); $code.val("重新获取"); validCode=true; } },1000) } })