为什么注释掉setInterval或者把延迟时间改到1分钟,文本框里面的时间还是每秒都在变化?
如题,这样一来感觉设置setInterval并没有起到什么作用啊。。。。求解
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>定时器</title> <script type="text/javascript"> var attime; function clock(){ var time=new Date(); var s=time.getSeconds(); if(s<10){ s="0"+s; } attime=time.getHours()+":"+time.getMinutes()+":"+s; document.getElementById("clock").value = attime; } var timer=setInterval(clock,1000*60); </script> </head> <body> <form> <input type="text" id="clock" size="50" style="width:60px;background-color:black;color:white;"/> </form> </body> </html>