/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <body> <input type="text" id="clock" /> <script language=javascript> var int=self.setInterval("clock()",1000); function clock() { var d=new Date(); var t=d.toLocaleTimeString(); document.getElementById("clock").value=t; } </script> </form> <button onclick="int=window.clearInterval(int)">Stop</button> </body> </html>
URL: http://www.w3schools.com/jsref/met_win_setinterval.asp