I have a php page with a variable that is set true or false on pageload. I want to show a specific div when the variable is true and then the div disappears after x seconds. When its false the div stays hidden.
My code shows the div but it doesn’t disappear after x seconds.
if($showNotification == TRUE){
echo "<div class='notification'>notification!!</div>";
echo '<script type="text/javascript">
$(document).load(
function() {
$("div.notification").fadeIn();
setTimeout(function() {
$("div.notification").fadeOut("slow");
}, 3000);
});
</script>';
}
Replace your JS with this:
Demo: http://jsfiddle.net/nEsg9/