JSFiddle - React, Tailwind, and code Playground
by _abl
HTML
<span id="counter"></span>
<div id="console"></div>
JavaScript
var counter;
function startCountDown(){
counter = 10;
var interval = setInterval(function() {
counter--;
// Display 'counter' wherever you want to display it.
document.getElementById("counter").innerHTML = "Timer:"+counter
if (counter == 0) {
// Submit form
out("Form submitted!");
startCountDown();
}
}, 1000);
}
startCountDown();
function out(msg){
var p = document.createElement("P");
p.appendChild(document.createTextNode(msg));
document.getElementById("console").appendChild(p);
}