js验证码倒计时

var wait=59;

function time(){

    if(wait >= 0){
        $("#buttons").val("" + wait + "s重新发送"); 
          wait--; 
          setTimeout(function() {  
                    time() 

                },1000)
      }else{

          $("#buttons").hide();

          $("#button").show();

          wait=59;


      }
};



$("#button").click(function(){

      $(this).hide();

      $("#buttons").show();
      
      time()


 });

  

posted @ 2015-06-26 17:23  唸随爱  阅读(161)  评论(0编辑  收藏  举报