JSFiddle - React, Tailwind, and code Playground
by AJIEKCEU
HTML
<input type="number" id="input" />
<input id="stop" type="button" value="stop"/>
<input id="start" type="button" value="start"/>
JavaScript
var timer = null,
interval = 1000,
value = 0;
$("#start").click(function() {
if (timer !== null) return;
timer = setInterval(function () {
value = value+1;
$("#input").val(value);
}, interval);
});
timer = setInterval(function () {
value = value+1;
$("#input").val(value);
}, interval);
$("#stop").click(function() {
clearInterval(timer);
timer = null
});