使用jQuery页面加载函数启动定时任务
var timer; $(document).ready(function(){ if (timer == undefined) timer = window.setInterval(showTime, 1000); }); //显示时间 function showTime() { var now = new Date(); document.getElementById("spanTime").innerHTML = now.toLocaleTimeString(); }
"唯有高屋建瓴,方可水到渠成"