html
<button id="YZM" type="button" onclick="saveCode(this);">
<span class="bigger-110">获取验证码
</button>
js
var countdown = 60;
saveCode=function (obj){
var telephone = $("#telephone").val().trim();
settime(obj);
}
function settime(obj) {
if(countdown == 1){
obj.removeAttribute("disabled");
$("#YZM>span").html("获取验证码");
countdown = 60;
return;
}
else{
obj.setAttribute("disabled","ture");
$("#YZM>span").html("重新获取("+ countdown +")");
countdown--;
}
console.log(11);
setTimeout(function () {
settime(obj)
},1000)
}