第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

兩個(gè)問題,一、;還沒有按start就開始計(jì)時(shí),二;按了stop沒反應(yīng)

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>計(jì)時(shí)器</title>


<script type="text/javascript">

? var num=0;

? var i;

? function startCount(){

? ? document.getElementById('count').value=num;

? ? num=num+1;

? ? i=setTimeout("startCount()",1000);

? }

?setTimeout("startCount()",1000);

? function stopCount(){

? ? ? ? clearTimeout(i);

? }

</script>

</head>

<body>

? <form>

? ? <input type="text" id="count" />

? ? <input type="button" value="Start" onclick="startCount()" />

? ? <input type="button" value="Stop" onclick="stopCount()"? />

? </form>

</body>

</html>


正在回答

6 回答

https://img1.sycdn.imooc.com//5d35143d000117a204540333.jpg

把這句代碼去掉就可以了,因?yàn)镴S在第一次執(zhí)行的時(shí)候,直接調(diào)用了開始函數(shù)

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕雪83909 提問者

o 知道了。可是為什么有的不加這句話就出不來呢‘’
2019-07-22 回復(fù) 有任何疑惑可以回復(fù)我~

<input type="button" value="Stop" onclick="clearTimeout()"/>

這段代碼對(duì)象名不能命名clearTinmeout ? 你可以命名成別的 ? stop按鈕就可以正常使用啦

可以參考js變量命名規(guī)則 ?不循序使用js關(guān)鍵字和保留字做變量名哦

0 回復(fù) 有任何疑惑可以回復(fù)我~

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>計(jì)時(shí)器</title>


<script type="text/javascript">

? var num=0;

? var i;

? function startCount(){

? ? ? clearTimeout(i);

? ? document.getElementById('count').value=num;

? ? num=num+1;

? ? i=setTimeout("startCount()",1000);

? }

? function stopCount(){

? ?clearTimeout(i);

? }

</script>

</head>

<body>

? <form>

? ? <input type="text" id="count" />

? ? <input type="button" value="Start" onclick=" startCount()" />

? ? <input type="button" value="Stop"? ?onclick=" stopCount()" />

? </form>

</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

按stop停止不了,大神,你是小哥哥嗎

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>計(jì)時(shí)器</title>

<script type="text/javascript">

? var num=0;

? function startCount() {

? ? document.getElementById('count').value=num;

? ? num=num+1;

? ? var i= setTimeout("startCount()",1000);

? }

? function clearTimeout()

? {

? clearTimeout(i);

? }

??

</script>

</head>

<body>

<form>

<input type="text" id="count" />

<input type="button" value="Start" onclick="startCount()"/>

<input type="button" value="Stop" onclick="clearTimeout()"/>

</form>

</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

因?yàn)槟愕谝淮螌懙氖窃邳c(diǎn)擊的時(shí)候調(diào)用startCount函數(shù),這個(gè)只有

https://img1.sycdn.imooc.com//5d351fdf00013d0104820546.jpg

初始化定時(shí)器會(huì)調(diào)用startCount函數(shù),

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕雪83909 提問者

0 好的,我還是沒有成功
2019-07-22 回復(fù) 有任何疑惑可以回復(fù)我~

這個(gè)去掉函數(shù)外邊的setTimeout()就出不來了

為什么呢


<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>計(jì)時(shí)器</title>

<script type="text/javascript">

? var num=0;

? function startCount() {

? ? document.getElementById('count').value=num;

? ? num=num+1;

? ? setTimeout("startCount()",1000);

? }

? ?setTimeout("startCount()",1000);

??

</script>

</head>

<body>

<form>

<input type="text" id="count" />

</form>

</body>

</html>




0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

兩個(gè)問題,一、;還沒有按start就開始計(jì)時(shí),二;按了stop沒反應(yīng)

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)