兩者區別是什么,為什么第二個會出現這種情況?
?var attime;
? function clock(){
? ? var time=new Date(); ? ? ? ? ?
? ? attime= time.getHours()+":"+time.getMinutes()+":"+time.getSeconds() ?; ;
? ? document.getElementById("clock").value = attime;
? }
? setInterval(clock,1000);
?var attime;
? function clock(){
? ? var time=new Date(); ? ? ? ? ?
? ? attime= time.getHours()+":"+time.getMinutes()+":"+time.getSeconds() ?; ;
? ? document.write(attime);
? }
? setInterval(clock,1000);
2016-06-08
如果在文檔已完成加載后執行 document.write,整個 HTML 頁面將被覆蓋
2016-06-08
因為每運行一次clock,都是一次新的開始。