html文件:<p id="clock"></p><input type="button" value="dianji" onclick="count()">js文件:function count(){ var time=new Date(); var attime= time.getHours()+"."+time.getMinutes()+"."+time.getSeconds() ; document.getElementById("clock").innerHTML=attime;}var attime = setInterval(count(),100);
1 回答
已采纳
stone310
TA贡献361条经验 获得超191个赞
<body> <p id="clock"></p> <input type="button" value="dianji" onclick="a()"> <script > function count(){ var time=new Date(); var attime= time.getHours()+"."+time.getMinutes()+"."+time.getSeconds() ; document.getElementById("clock").innerHTML=attime; } function a(){ setInterval(count,100); } </script> </body>
或者
<body> <p id="clock"></p> <input type="button" value="dianji" onclick="count()"> <script > function count(){ var time=new Date(); var attime= time.getHours()+"."+time.getMinutes()+"."+time.getSeconds() ; document.getElementById("clock").innerHTML=attime; setTimeout(count,100) } </script> </body>
添加回答
举报
0/150
提交
取消