JSFiddle - React, Tailwind, and code Playground
HTML
<div id="hideMsg">
The entry you posted not valid.
This Box will Close In <span>2</span> Seconds
</div>
JavaScript
var sec = 2
var timer = setInterval(function() {
$('#hideMsg span').text(sec--);
if (sec == -1) {
$('#hideMsg').fadeOut('fast');
clearInterval(timer);
}
}, 1000);