JSFiddle - React, Tailwind, and code Playground

by alnitak

HTML

<input type="number" id="input" value="0" />
<input type="button" id="stop" value="stop"/>
<input type="button" id="start" value="start"/>

JavaScript

var timer = null;
var input = document.getElementById('input');

function tick() {
    ++input.value;
};

function start() {
    tick();
    timer = setTimeout(start, 1000);
};

function stop() {
    clearTimeout(timer);
};

$('#start').click(start);
$('#stop').click(stop);