验证码60秒倒计时
验证码60秒倒计时(jQuery),
代码如下:
//验证码倒计时 var countdown = 60; var st; function settime(element) { if (countdown != 0) { st = setTimeout(function () { settime(element); }, 1000); } if (countdown == 0) { element.removeAttr("disabled"); element.val("获取验证码"); element.removeAttr("style"); countdown = 60; window.clearTimeout(st); } else { element.attr("disabled", true); element.css({"background":"#CCC","color":"#fff"}); element.val("重新发送(" + countdown + ")"); countdown--; } }