Auto Close Div Alert
by Paul Leech
HTML
<button id="d">alert</button>
JavaScript
function tempAlert(msg,duration)
{
var el = document.createElement("div");
el.setAttribute("style","position:absolute;top:40%;left:20%;background-color:white;border:1px #999 solid;padding:2rem");
el.innerHTML = msg;
setTimeout(function(){
el.parentNode.removeChild(el);
},duration);
document.body.appendChild(el);
}
var d = document.getElementById('d');
d.onclick = function(){ tempAlert("Record Updated",2500); };