js 發送短信 倒計時

 //倒計時
      function resetCode(){
          $('.J_getCode').hide();
          $('.J_second').html('60');
          $('.J_resetCode').show();
          var second = 60;
          var timer = null;
          timer = setInterval(function(){
              second -= 1;
              if(second >0 ){
                  $('.J_second').html(second);
              }else{
                  clearInterval(timer);
                  $('.J_getCode').show();
                  $('.J_resetCode').hide();
              }
          },1000);
      };



      $(function () {
          //點擊發送驗證碼
          var isPhone = 1;
          $(".J_getCode").click(function(){
              isPhone = 1;
              $.post('url',{
              },function(result){
                  if(result.success){
                      resetCode(); //倒計時
                      showMsgSuccess("獲取驗證碼成功");
                  }else{
                      showMsgError("獲取驗證碼成功");
                  }
              },'json');

          });

})
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章