好奇怪,改了 var int=setInterval(clock, 3000),还是间隔一秒?为什么呢
改大了好多还是没变化
改大了好多还是没变化
2015-04-14
clock写的有问题吧。这样写是木有问题的。
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>定时器</title> <script type="text/javascript"> var attime; var colorHead,colorFoot; function clock(){ var time=new Date(); var HH = time.getHours(); if(HH<10){HH="0"+HH}; var MM = time.getMinutes(); if(MM<10){MM="0"+MM}; var SS = time.getSeconds(); if(SS<10){SS="0"+SS}; var ww = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"] var nWeek = time.getDay(); attime= HH+":"+MM+":"+SS+" "+ww[nWeek]; document.getElementById("clock").value = attime; } var timer = setInterval(clock,1000); </script> </head> <body> <form> <input type="text" id="clock" size="50" /> </form> </body> </html>
这样就可以每3秒执行一次了。
举报