验证码倒计时

<input type="button" id="butt" value="发送验证码"/ style="width: 100px;height: 36px; border: 1px solid #4ea7ff;border-radius: 6px;margin-left: 12px; color: #3399ff;cursor: pointer;">
 
//发送验证码
var wait = 60;

function time(btn) {
//yuliangjie 加if判断
if (wait == 0) {
btn.removeAttribute("disabled");
btn.value = "获取验证码";
wait = 60;
} else {
btn.setAttribute("disabled", true);
btn.value = "重新发送"+ (wait);
wait--;
setTimeout(function () {
time(btn);
},
1000)
}

}

$('#butt').on('click', function () {
console.log(11111);
time(this);
var num = "${phone}";
$.post('${webRoot}/add/getCodeInfo.html', {phone: num}, function (data) {
codee = data.code;
});
});
posted @ 2018-04-02 20:27  dyjiang  阅读(155)  评论(1编辑  收藏  举报