JSFiddle - React, Tailwind, and code Playground
HTML
<div id="main"></div>
JavaScript
var timer = 15;
setInterval(function() {
timer--;
if (!timer) {
//do the action
$('#main').html("Redirecting now!");
timer = 15;
} else if (timer <= 5) {
$('#main').html("Redirecting in " + timer + " seconds");
}
console.debug(timer);
}, 1000);
$(document).on('ready keypress mousemove focus', function() {
timer = 15;
});