<!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/css布局实践.css"> <script type="text/javascript"> function clock(){ var time = new Date(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); var noon = "AM"; if(hour>12){ noon = "PM"; } if(hour<10){ hour = "0"+hour; } if(minute<10){ minute = "0"+minute; } if(second<10){ second = "0"+second; } var clock_text = hour+":"+minute+":"+second+" "+noon; var dis_text = document.createTextNode(clock_text); var dis = document.getElementById("display"); dis.appendChild(dis_text); setTimeout(clock(),10000); } </script> <title>无标题文档</title> </head> <body onLoad="clock()"> <div id="display"></div> </body> </html>
这个错误是怎么造成的,按说这个函数应该每间隔一秒钟为id为display的div元素添加一个文本节点啊。。。怎么一下子会出来那么多呢
_亓
merry_离
相关分类