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

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

.onclick=function(){}這種形式的問題

<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>計時器</title>
</head>
<script?type="text/javascript">
??var?num=0;
??var?i;
??var?start=document.getElementById('start');
??var?stop=document.getElementById('stop')
?start.onclick=function(){
????document.getElementById('count').value=num;
????num=num+1;
????i=setTimeout("startCount()",1000);
??}
stop.onclick=?function(){
??clearTimeout(i);
??}
</script>
</head>
<body>
??<form>
????<input?type="text"?id="count"?/>
????<input?type="button"?id="start"?value="Start"??/>
????<input?type="button"?id="stop"?value="Stop"???/>
??</form>
</body>
</html>
請問這樣為什么不可以?


正在回答

3 回答

i=setTimeout("startCount()",1000);???? 里面startCount()?? 幾個意思?

0 回復 有任何疑惑可以回復我~
<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>計時器</title>
</head>
</head>
<body>
??<form>
????<input?type="text"?id="count"?/>
????<input?type="button"?id="start"?value="Start"/>
????<input?type="button"?id="stop"?value="Stop"/>
??</form>
</body>
<script?type="text/javascript">
??var?num=0;
??var?i;
??var?start=document.getElementById('start');
??var?stop=document.getElementById('stop');
??start.onclick=function(){
????document.getElementById('count').value=num;
????num=num+1;
????i=setTimeout("startCount()",1000);
??}
??stop.onclick=?function(){
????clearTimeout(i);
??}
</script>
</html>

把script部分放到下面來,你執行腳本的時候,html元素可能還沒加載到。

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

?var?stop=document.getElementById('stop')后面加個分號看下

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

天晴云開 提問者

還是不可以,js會自動補分號
2015-08-12 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

.onclick=function(){}這種形式的問題

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

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

幫助反饋 APP下載

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

公眾號

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