I need to hide a div
(like "mail sent successful" in Gmail) after a certain time period when I reload the page.
How can I do that?
If you want to make a unobstrusive feature, you should let the div visible by default. When the page is correctly loaded, the first task to do is to hide the DIV with jQuery, and then, run an animation to show it in 5s. By doing this way, if there is no JS activated, the DIV is already available.
To hide an element, set the style display property to “none”. document. getElementById("element").
You can use setTimeout like this: setTimeout(function(){ $('#divID'). remove(); }, 5000); The 5000 (ms) means 5 seconds.
Here's a complete working example based on your testing. Compare it to what you have currently to figure out where you are going wrong.
<html> <head> <title>Untitled Document</title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready( function() { $('#deletesuccess').delay(1000).fadeOut(); }); </script> </head> <body> <div id=deletesuccess > hiiiiiiiiiii </div> </body> </html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With