Basic example; update every 1 ms
click start
to start a stopwatch
var elems = document.getElementsByClassName("basic"); for (var i=0, len=elems.length; i
Programmatic example
Note: despite the varying
delay
settings, each stopwatch displays the correct time (in seconds)var a = document.getElementById("a-timer"); aTimer = new Stopwatch(a); aTimer.start();1 ms
var b = document.getElementById("b-timer"); bTimer = new Stopwatch(b, {delay: 100}); bTimer.start();100 ms
var c = document.getElementById("c-timer"); cTimer = new Stopwatch(c, {delay: 456}); cTimer.start();456 ms
var d = document.getElementById("d-timer"); dTimer = new Stopwatch(d, {delay: 1000}); dTimer.start();1000 ms