Using javascript i want to show error message, and the message will hide/disappear after 2 second . The error show perfectly and hide after 2 second but it does not work for the second time. if i reload my page it work perfectly again and so on.
JavaScript
if(task_hour == "hour" || task_minute == "minute"){
document.getElementById("error").innerHTML = "Add Time for the Task";
setTimeout(function(){ document.getElementById("error").style.display="none"; }, 2000);
return false;
}
HTML
<div id="errordiv" align="center" style="margin-left: auto; margin-right: auto;">
<span id="error" style="color: red"> </span>
</div>
display: <smth>to show it anddisplay: noneto hide.none, and you never reset it toblockto make it visible again.