<strong>第一種方法:</strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="32452" class="copybut" id="copybut32452" onclick="doCopy('code32452')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code32452"> <br> <br> <br> <br> <br><title>定時器</title> <br><script language="javascript" src="jquery-1.4.2.js"></script> <br><script language="javascript"> <BR>//使用setInterval間歇呼叫(不建議使用此方法) <BR>$(function(){ <BR>setInterval(function(){ <BR>$("#currentTime").text(new Date().toLocaleString()); <BR>}, 1000); <BR>}); <BR></script> <br> <br> <br><div id="currentTime"></div> <br> <br> <br> </div> <br><strong>第二種方法:</strong> <br><div class="codetitle"><span><a style="CURSOR: pointer" data="24166" class="copybut" id="copybut24166" onclick="doCopy('code24166')"><u>複製程式碼</u></a></span></div>複製程式碼<div class="codebody" id="code24166"> <br><br><br>複製程式碼<br><br><br><br>複製程式碼<br><br><br><br>複製程式碼<br><br><br><br>複製程式碼<br><br><br><br>複製程式碼</div> <br><strong></strong>複製程式碼<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="2139" class="copybut" id="copybut2139" onclick="doCopy('code2139')">複製碼><u> 程式碼如下:</u></a> </span>pageEncoding="UTF-8"%> <div class="codebody" id="code2139"> <br> <br><title>定時器</title> <br><script language="javascript" src="jquery-1.4.2.js"></script> <br><script language="javascript "> <BR>//使用setTimeout逾時呼叫<BR>function startTime(){ <BR>$("#currentTime").text(new Date().toLocaleString()); <BR>setTimeout('startTime( )',1000); <BR>} <BR></script> <br> <br> <br><div id="currentTime"> div> <br> <br> </div> </div> </div>