JSFiddle - React, Tailwind, and code Playground

by tiagocarvalho

HTML

<div id="hideMsg">
The entry you posted not valid.
This Box will Close In <span>5</span> Seconds
</div>

JavaScript

$(function() {
    var timer, counter = $("#hideMsg span").text();
    $('#hideMsg').delay(counter * 1000).fadeOut('fast');
    timer = setInterval(function() {
        $("#hideMsg span").html(--counter);
        if (counter == 0) { clearInterval(timer)};
    }, 1000);
});