30秒後重新發送驗證碼

  </ HTML>
  <HEAD>
  <meta charset =“utf-8”/>
  <TITLE>短信驗證碼</ TITLE>
  </ HEAD>
  <style type =“text / css”>
   
  </樣式>
  <BODY>
  <! - 點擊“獲取驗證碼”按鈕,後顯示“30秒後重新發送”,秒數遞減,然後將“獲取驗證碼”按鈕置爲不可用狀態,達到0秒後重新置爲可用 - >
  <input type =“text”placeholder =“請輸入驗證碼”>
  <input type =“button”value =“獲取驗證碼”id =“btn”/>
  </ BODY>
  <script type =“text / javascript”>
  obutton =的document.getElementById( 'BTN')
  obutton.onclick =函數(){
  this.disabled = TRUE;
  // this.setAttribute('disabled','true')
  this.value = 30 +“秒後重發”;
  計時器= setInterval的(函數(){
  // console.log(obutton.value)
  第二= parseInt函數(obutton.value)
  if(second <= 1){
  obutton.disabled = FALSE;
  obutton.value = “獲取驗證碼”;
  clearInterval(定時器);
  計時器= NULL;
  }其他{
  // console.log(第二個)
  obutton.value =(第二-1)+ “秒後重發”;
  };
  },1000);
  };
  </ SCRIPT>
  </ HTML>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章