<strong>First method: </strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="32452" class="copybut" id="copybut32452" onclick="doCopy('code32452')"><u>Copy code </u></a></span> The code is as follows: </div> <div class="codebody" id="code32452"> <br>< ;%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html> <br><head> <br>< title>Timer</title> <br><script language="javascript" src="jquery-1.4.2.js"></script> <br><script language="javascript"> ; <br>//Use setInterval to call intermittently (this method is not recommended) <br>$(function(){ <br>setInterval(function(){ <br>$("#currentTime").text(new Date ().toLocaleString()); <br>},1000); <br>}); <br></script> <br></head> <br><body> <br>< div id="currentTime"></div> <br></body> <br></html> <br> </div> <br><strong>Second method: </strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="24166" class="copybut" id="copybut24166" onclick="doCopy('code24166')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code24166"> <br><%@ page language="java" contentType=" text/html; charset=UTF-8" <BR>pageEncoding="UTF-8"%> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><head> <br><title>Timer</title> <br><script language ="javascript" src="jquery-1.4.2.js"></script> <br><script language="javascript"> <br>//Use setTimeout to call <br>function startTime( ){ <br>$("#currentTime").text(new Date().toLocaleString()); <br>setTimeout('startTime()',1000); <br>} <br></script> ; <br></head> <br><body onload="startTime()"> <br><div id="currentTime"></div> <br></body> <br></html> <br> </div> <br><strong>Third method: </strong> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="2139" class="copybut" id="copybut2139" onclick="doCopy('code2139')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code2139"> <br><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><head> <br><title>Timer</title> <br><script type="text/javascript"> <br>var c=0; <br>var t; <br>function timedCount(){ <br>document.getElementById('txt').value=c; <br>c=c 1; <br>t=setTimeout("timedCount()",1000); <br>} <br>function stopCount(){ <br>clearTimeout(t); <br>} <br></script> <br></head> <br><body> <br><form> <br><input type="button" value="Start timing! " onclick="timedCount()"/> <br><input type="text" id="txt"/> <br><input type="button" value="Stop timer! " onclick="stopCount()"/> <br></form> <br></body> <br></html> <br> </div>