js:
//倒计时
var countdown=60,t;
function settime(){
if (countdown == 0) {
$("#validateBtn").attr("onclick","smsValidateCode();");//移除onclick事件
$("#validateMsg").text('发送验证码');
clearTimeout(t);
countdown = 60;
} else {
$("#validateBtn").removeAttr("onclick");
$("#validateMsg").text('重新发送(' + countdown + 's)');
countdown--;
t = setTimeout(function() {settime()},1000);
}
}
页面:
<a class="checkbtn fl" style="cursor: pointer;" onclick="smsValidateCode();" id="validateBtn">
<span id="validateMsg">发送验证码</span>
</a>