/ Published in: JavaScript
Just a counter
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var count = 0; var timer; var timerOn = false; function timedCount() { count++; timer = setTimeout(function(){ timedCount() }, 1000); } function doTimer() { if (!timerOn) { timerOn = true; timedCount(); } } function stopCount() { clearTimeout(timer); timerOn = false; }