function timeClock()
{
setTimeout("timeClock()", 1000);
now = new Date();
alert(now);
f_date = now.getDate()+" "+strMonth(now.getMonth())+" "+now.getFullYear()+" / "+timeFormat(now.getHours(), now.getMinutes());
return f_date;
}
<span class="foo"><script type="text/javascript">document.write(timeClock());</script></span>
Run Code Online (Sandbox Code Playgroud)
警报(现在的); 每秒给我一个值,但它没有在html中更新.如何在不刷新页面的情况下更新html的时间?