var $timeBox = $(".btn-verify"), setTime = 5, paramTime, Message = { second: '秒后获取', verify: '获取验证码' };
function funTimeout() { paramTime--;
$timeBox.html(paramTime + Message.second);
if (paramTime == 0) { $timeBox.addClass('able').html(Message.verify); } else { setTimeout("funTimeout()", 1000); }
}
$(function () {
$timeBox.on('click', function () { var $this = $(this); if ($this.hasClass('able')) { $this.removeClass('able'); paramTime = setTime; funTimeout(); } })
})
|