JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<style>
p { color: white; background: #ff0000; }
p:empty {
width: 100px;
height: 20px;
background: #ff0000;
display:none;
}
</style>
</head>
<body>
<p id="xd">Click the button, wait 2 seconds, then this will be hidden.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
setInterval(function(){ document.getElementById("xd").innerHTML = ""; }, 2000);
}
</script>
</body>
</html>