Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide a div after some time period?

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?

like image 487
rag Avatar asked Mar 11 '10 15:03

rag


People also ask

How do you show divs after 5 seconds?

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.

How do I disappear a div?

To hide an element, set the style display property to “none”. document. getElementById("element").

How do you delete a div in 5 seconds?

You can use setTimeout like this: setTimeout(function(){ $('#divID'). remove(); }, 5000); The 5000 (ms) means 5 seconds.


1 Answers

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> 
like image 155
rosscj2533 Avatar answered Oct 07 '22 02:10

rosscj2533