I am making a simple timer in javaScript which starts when you click anywhere in the document and it resets on clicking again.
var k = 0,
m = 0,
s = 0;
document.onclick =
function() {
k = 0;
setTimeout(function() {
k++;
if (Math.floor(k / 6000) > 1) {
m = Math.floor(k / 6000);
s = Math.floor(k % 6000);
} else
s = Math.floor(k / 100);
document.getElementById('input3').value = "0" + m + ":" + "0" + s + " " + k;
}, 10);
};
input3 is the id of textbox in html in timer in which countdown is displayed
setTimeout()schedules a function to be invoked once. You may be interested in the related functionsetInterval().