JSFiddle - React, Tailwind, and code Playground
by erickeno
HTML
<h2>what time is is it <a id="counter"> 0</a></h2>
<input type="button" id="startButton" value="Click Me"></input>
JavaScript
var counter = 0;
$("#startButton").click(function () {
var updateCounter = function () {
if (counter <= 19) {
counter++;
document.getElementById("counter").firstChild.nodeValue = counter;
} else {
clearInterval();
document.getElementById("counter").firstChild.nodeValue = "";
}
}
timer2 = setInterval(updateCounter, 1000);
});