JSFiddle - React, Tailwind, and code Playground
HTML
<p id="countdown2"></p>
CSS
p {
color: #1B232F;
font-family: Verdana, Arial, sans-serif;
font-size: 18px;
font-weight: bold;
text-decoration: none;
}
JavaScript
countdown("countdown2", 50, 0);
function countdown(element, minutes, seconds) {
var time = minutes*60 + seconds;
var interval = setInterval(function() {
var el = document.getElementById(element);
if(time == 0) {
el.innerHTML = "countdown's over!";
clearInterval(interval);
return;
}
var minutes = Number.floor( time / 60 );
if (minutes < 10) minutes = "0" + minutes;
var seconds = time % 60;
if (seconds < 10) seconds = "0" + seconds;
var text = minutes + ':' + seconds;
el.innerHTML = text;
time--;
}, 1000);
}