JSFiddle - React, Tailwind, and code Playground
PB + CD
by Dumine Stefan Daniel
HTML
<div id="countdown"></div>
<div id="myProgress">
<div id="myBar">0%</div>
</div>
<br>
CSS
#myProgress {
width: 100%;
background-color: #ddd;
}
#myBar {
width: 0%;
height: 30px;
background-color: #4CAF50;
text-align: center;
line-height: 30px;
color: white;
}
JavaScript
function ShowTime() {
var now = new Date();
var mins = 60-now.getMinutes();
var secs = 60-now.getSeconds();
timeLeft = "" + mins+' minutes '+secs+' seconds';
$("#countdown").html(timeLeft);
}
pb();
;
function StopTime() {
clearInterval(countdown);
}
ShowTime();
var countdown = setInterval(ShowTime ,1000);
function pb() {
var elem = document.getElementById("myBar");
var width = 0;
var id = setInterval(frame, 1000);
function frame() {
if (width >= 180000) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
elem.innerHTML = width * 1 + '%';
}
}
}