確認コードを取得するためのjsカウントダウン

 

公式住所 

使い方は簡単ですが、リフレッシュしないでください!

 

 

 

<input type = "text" name = "code"> <button class = "captchaBtn">获取短信验证码</ button> 


<script> 
    $(function (){ 
        $( ".captchaBtn")。on( "click "、function (){
             // ... 
            countdown(this );
             // ... 
        })
    }); 


function countdown(obj){
         var that = $(obj);
         var seconds = 60 ; 
         that.attr( "disabled"、true ); 
         that.html(seconds + '  ' );= 新しい新しい約束((解決、拒否)=> { 
          のlet SETTIMER = のsetInterval( 
            () => {  - = 1。;
               // console.info( 'カウントダウン'秒+); 
              that.html(+秒'第2' ;
               if(seconds <= 0 ){ 
                  that.html( 'Get SMS Verification Code' ); 
                resolve(setTimer)
              } 
            }  1000 
        })
        promise.then((setTimer) => {
           // console.info( '清除'); 
          clearInterval(setTimer); 
          that.attr( "disabled"、false ); 
        })
}
 </ script>

 

 

おすすめ

転載: www.cnblogs.com/coder1013/p/12689084.html