JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" value="DrĂĽck mich so lange du willst" onMouseDown="mousedown()" onMouseUp="mouseup()" />
<input type="text" id="dauer" value="0ms" readonly>

JavaScript

var starttime;
var textbox;
var total;
var interval;
function count(){
	total = (new Date()).getTime() - starttime;
	textbox.value = total + "ms";
}	
function mousedown(){
	starttime = (new Date()).getTime();
	total = 0;
	textbox = document.getElementById('dauer');
	interval = window.setInterval("count()",1);
}
function mouseup(){
	window.clearInterval(interval);
}