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

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

怎么不能實現呢

<!doctype html>
<html>
<head>
??? <meta charset="UTF-8">
?<title>Document</title>
??? <style>
??????? #receive{display:none;}
???????
??? </style>
?<script type="text/javascript">
?window.onload=function(){
???? var send=document.getElementById('send'),
??????????? receive=document.getElementById('receive'),
???????? times=60,
???????? timer=null;
???? send.onclick=function(){
?????? // 計時開始
????????? timer=setInterval('showTime',500);????????
???? }
??????? function showTime(){
??????????? if(times>=0){
????????????? receive.style.display='block';
??????????????? receive.disabled ='false';
??????????????? receive.value=times+'秒后重試';
??????????????? times--;
????send.disabled='false';
??????????? }
??????????? else{????
????clearInterval(timer);
????? receive.style.display='none';
??????????? }
??????? }
?}
?</script>
</head>
<body>
?<input type="button" id="send" value="發送驗證碼" >
??? <input type="button" id="receive" >
</body>
</html>

正在回答

1 回答

setInterval()調用出錯。 正確的調用方式如下:

?? timer=setInterval('showTime()',500);??????? 或 ?? timer=setInterval(showTime,500);????????

定義和用法

setInterval() 方法可按照指定的周期(以毫秒計)來調用函數或計算表達式。

setInterval() 方法會不停地調用函數,直到 clearInterval() 被調用或窗口被關閉。由 setInterval() 返回的 ID 值可用作 clearInterval() 方法的參數。

語法??? setInterval(code,millisec[,"lang"])?

參數???? 描述

code ? ?必需。要調用的函數或要執行的代碼串。 ? ?

millisec ? ?必須。周期性執行或調用 code 之間的時間間隔,以毫秒計。 ? ?


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

舉報

0/150
提交
取消

怎么不能實現呢

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

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

幫助反饋 APP下載

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

公眾號

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