JSFiddle - React, Tailwind, and code Playground
HTML
<div id="d">alert</d>
JavaScript
function tempAlert(msg,duration)
{
var el = document.createElement("div");
el.setAttribute("style","position:absolute;top:40%;left:20%;background-color:white;");
el.innerHTML = msg;
setTimeout(function(){
el.parentNode.removeChild(el);
},duration);
document.body.appendChild(el);
}
var d = document.getElementById('d');
d.onclick = function(){ tempAlert("close",500); };