Jquery时倒计时按钮

Html 按钮

< button id ="sendEmailButton" type ="button" onclick ="sendEmail()" >获取邮箱验证码</button >

js

function sendEmail(){
       var count = 80;
       var countdown = setInterval(CountDown, 1000);
       function CountDown() {
       $( "#sendEmailButton").attr("disabled" , true);
       $( "#sendEmailButton").text(count+"秒后重新获取!" );
       if (count == 0) {
       $( "#sendEmailButton").text("获取邮箱验证码" ).removeAttr("disabled");
       clearInterval(countdown);
       }
       count--;
       }
}




你可能感兴趣的:(Jquery时倒计时按钮)