有没有办法alert()
自动关闭JavaScript ?
我有一个警报
alert("Error found");
我想在几秒钟后关闭它。那有可能还是我应该去参加jQuery对话
警报无法实现此功能。但是,您可以使用div
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);
}
像这样使用:
tempAlert("close",1000);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句