Set and stop a timer using javascript

Prabhukiran345
Posted by Prabhukiran345 under JavaScript category on | Points: 40 | Views : 857
Script:
<script>
var int=self.setInterval(function(){clock()},1000);
function clock()
{
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("clock").value=t;
}
</script>

HTML CODE:
<body>
<input type="text" id="clock" />
<button onclick="int=window.clearInterval(int)">Stop</button>
</body>

Comments or Responses

Login to post response