課程
/前端開發(fā)
/JavaScript
/JavaScript進(jìn)階篇
哪里有問(wèn)題?
2014-06-04
源自:JavaScript進(jìn)階篇 8-4
正在回答
1.事件onclick后面不用括號(hào); 2.clearInterval()中的參數(shù)是setInterval()的返回值。 3. stop標(biāo)簽還少一個(gè)id="stop" var t; window.onload=function(){ function clock(){ var time=new Date(); document.getElementById("clock").value = time; } var starBtn=document.getElementById("star"); var stopBtn=document.getElementById("stop"); starBtn.onclick=function(){ t=setInterval(clock,1000); } stopBtn.onclick=function(){ clearInterval(t); } } 在對(duì)比下,試一試。
舉報(bào)
本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁(yè)動(dòng)態(tài)交互世界
49 回答
13 回答
17 回答
14 回答
18 回答
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2014-06-06
1.事件onclick后面不用括號(hào); 2.clearInterval()中的參數(shù)是setInterval()的返回值。 3. stop標(biāo)簽還少一個(gè)id="stop" var t; window.onload=function(){ function clock(){ var time=new Date(); document.getElementById("clock").value = time; } var starBtn=document.getElementById("star"); var stopBtn=document.getElementById("stop"); starBtn.onclick=function(){ t=setInterval(clock,1000); } stopBtn.onclick=function(){ clearInterval(t); } } 在對(duì)比下,試一試。