setInterval使用 每隔一定时间执行操作
<html><head><title>每5秒执行一次操作</title><script language="javascript" type="text/javascript">function time1(){var d = new Date();var hour = d.getHours();var minute = d.getMinutes();var second = d.getSeconds();var time = hour+ ":"+minute +":"+ second;document.getElementById("s").value =time;}function time2(){var d = new Date();var hour = d.getHours();var minute = d.getMinutes();var second = d.getSeconds();var dd = new Date("12:00:00");var time = hour+ ":"+minute +":"+ second;document.getElementById("ss").value = time;}setInterval("time1()", 1000);setInterval("time2()", 2000);</script></head><body>每隔1秒执行一次 :<input type="text" id="s" /><br />每隔2秒执行一次 :<input type="text" id="ss" /></body></html>