JSFiddle - React, Tailwind, and code Playground

by informativejavascript

HTML

<input type="text" id="i1"/>
<button id="start">start</button>
<button id="stop">stop</button>
<button id="reset">reset</button>

JavaScript

(function(){
var counter=0;
	var timer=0;
$('#start').on('click',function(){
    timer=setInterval(function(){
    	$('#i1').val(++counter);
    },1000);
});

$('#stop').on('click',function(){
	clearInterval(timer);
	});

$('#reset').on('click',function(){
	$('#i1').val(0);
	counter=0;
	});
})();