铁塔山城😄 lychmi
关注数: 87 粉丝数: 104 发帖数: 1,588 关注贴吧数: 67
小白求助~~不知道哪里出错了 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <style type="text/css"> #jishi{ color:red; } #geshu{ color:red; width:0px; background:yellow; } .box { width:100px; border:solid 1px black; } </style> <script> window.onload = init; function init(){ var obj =document.body; obj.bgColor="white"; } var newcount =0; var nowcount =0; function newstar(){ var star = document.createElement("img"); star.src = "image/xingxing.gif"; var bd=document.body; bd.appendChild(star); var maxX=1800; var maxY=800; var x=Math.floor( Math.random() * maxX); var y=Math.floor(Math.random()*( maxY-150+1) ) + 150; //var y = Math.floor( Math.random() * ( maxY-20+1) ) + 20; star.style.position="absolute"; star.style.left=x+"px"; star.style.top=y+"px"; var w=Math.floor(Math.random()*( 80-20+1) )+20; star.width=w; star.onclick=xiaoshi; newcount++; var overtime=newcount*0.4; document.getElementById("jishi").innerHTML=Math.round(overtime)+"秒"; nowcount++; document.getElementById("geshu").innerHTML = nowcount; } function xiaoshi(){ document.body.removeChild( this ); nowcount--; document.getElementById("geshu").innerHTML = nowcount; } function begin(){ window.setInterval("newstar()",400) } </script> <title>Document</title> </head> <body> <!--<input type="button" value="开始" onclick="begin()" /> <span id="jishi">0秒<span> <div class="box"> <div id="geshu">0</div> </div>--> <table > <tr> <td width="100"> <input type="button" value="开始" onclick="begin()" /> <span id="jishi">0秒</span> </td> <td> <div class="box"> <div id="geshu">0</div> </div> </td> </tr> </table> </body> </html> 这段代码为什么注释部分里面执行不了但是用TABLE包起来就能运行了? 直接用DIV测试里显示document.getElementById("geshu").innerHTML = nowcount; document.getElementById("geshu").innerHTML = nowcount; 这两行有问题。
1 下一页