javascript - Display error message for 3 seconds and then fades out -
based on php file returns want show message on top of web page.
$msg = "success"; // or fail $redirecturl = "index.php?msg=".$msg; header("location: $redirecturl");
html code
<?php $msg=isset($_get['msg']) ? $_get['msg'] : "";?> <div id="display-success"><?php echo $msg; ?></div>
now if success
message need print small box appears (for 3 seconds, fades out) shows message success
in green background. , if failure
want display message in red background 3 seconds , fades out.
//by using settime0ut settimeout(function() { $('#display-success').fadeout().text('') }, 10000 ); //by using delay() $('#display-success').fadein().delay(10000).fadeout();
example demo
jquery
$(".showmsg").click(function () { $('#display-success').fadein().delay(3000).fadeout(); });
html
<button class="showmsg">click me</button> <div id="display-success">the error message</div>
Comments
Post a Comment