Tiny JS library for creating a stopwatch fast and simple!
- Download stopwatch.js
- Load module into your project (please see example.js or example setup below)
<div class="display">
<span class="stopwatchSpan">00:00:00</span>
</div>
<div class="buttons">
<button data-command="start" class="btn">Start</button>
<button data-command="stop" class="btn">Stop</button>
<button data-command="reset" class="btn">Reset</button>
</div>
import {Stopwatch} from './dist/stopwatch.js'
const DOM = {
stopwatchSpan: document.querySelector('.stopwatchSpan'),
buttons: document.querySelector('.buttons');
};
// Instantiate stopwatch (pass span, where stopwatch has to display, as parameter)
const sw = new Stopwatch(DOM.stopwatchSpan);
// Make control buttons to work
sw.configureButtons(DOM.buttons)