亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

代碼在自己的編輯器上跑起來了

<!doctype html>

<html lang="en">


<head>

<meta charset="UTF-8">

<title>Document</title>

<!-- 任務

第一步、獲取按鈕、綁定事件、設置定時器變量和計時變量


第二步、添加定時器,每隔1秒鐘計時減 1,直至當計時小于等于 0 時清除定時器,按鈕恢復為“發送驗證碼”,否則顯示為“X秒后重試” -->

<script type="text/javascript">

window.onload = function () {

var send = document.getElementById('send'),

times = 60,

timer = null;

send.onclick = function () {

// 計時開始


timer =setInterval(function(){

send.value=times+"秒后重試"

document.getElementById("send").disabled=true;

times--;

if(times<=0){

clearInterval(timer);

document.getElementById("send").disabled=false;

send.value="發送驗證碼";

}

},1000);


}

}

</script>

</head>


<body>

<input type="button" id="send" value="發送驗證碼">

</body>


</html>


正在回答

1 回答

在設置定時器之前,要先清除準備執行的定時器

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

代碼在自己的編輯器上跑起來了

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號