JSFiddle - React, Tailwind, and code Playground
by Lena R
HTML
<div class = "timer"></div>
CSS
.timer{
height:100px;
width:100px;
background:#6700ff;
color: yellow;
font-size: 25pt;
}
JavaScript
function second(){
var timer = document.querySelector('.timer');
window.timer = setInterval(function(){
var now = (new Date()).getSeconds();
var finish = 59 - (new Date()).getSeconds();
now--;
if(now === 0) clearInterval();
timer.innerHTML = finish;
});
}
second();