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

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

按stop停不下來(lái),而且時(shí)鐘不是一秒跳1秒,而是一秒跳3秒甚至5秒的數(shù),總之很怪異。

<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>計(jì)時(shí)器</title>
</head>
<script?type="text/javascript">
??var?num=0;
??var?i;
??function?startCount(){
????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>

http://img1.sycdn.imooc.com//58003d660001e4ab06200396.jpg

正在回答

6 回答

?<input?type="button"?value="Start"?onClick("startCount()")?/>
????<input?type="button"?value="Stop"?onClick("stopCount()")??/>
????<!--這里onclick后面不是用“=”嗎?這括號(hào)目前我是沒(méi)見(jiàn)過(guò)有用過(guò)-->


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

每點(diǎn)一次start按鈕,就會(huì)調(diào)用一次startCount()函數(shù),所以計(jì)時(shí)速度就會(huì)加快。

如果想停止就,點(diǎn)相應(yīng)次數(shù)的stop。

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

function startCount(){
?clearTimeout(i);
?document.getElementById('count').value=num;
?num=num+1;
?i=setTimeout("startCount()",1000);
}

主要的原因是你在start里面沒(méi)有清除原來(lái)的定時(shí)器, 如果點(diǎn)擊多次之后, stop也需要點(diǎn)擊多次才會(huì)停止所有已開(kāi)啟的定時(shí)器

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

大概看了下,本身邏輯沒(méi)有問(wèn)題,把下面的點(diǎn)擊事件后面改成"="試試

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

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


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

<!DOCTYPE HTML>

<html>

<head>

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

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

</head>

<script type="text/javascript">

var num=0;

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>


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

<script?type="text/javascript">

??var?num=0;

??var?i;

??function?startCount(){

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

? ?for(i=0;i<num.length;i++) {

? ?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ù)我~

舉報(bào)

0/150
提交
取消

按stop停不下來(lái),而且時(shí)鐘不是一秒跳1秒,而是一秒跳3秒甚至5秒的數(shù),總之很怪異。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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