Hide div with setTimeout


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>hide div com setInterval</title>
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
  7. <script>
  8. $(document).ready(function() {
  9. function sumir_floater() {
  10. var div = $("#floater");
  11. div.fadeIn();
  12. div.queue(function() {
  13. setTimeout(function() {
  14. div.dequeue();
  15. }, 5000);
  16. });
  17. div.fadeOut("fast");
  18. }
  19.  
  20. sumir_floater();
  21.  
  22. });
  23. </script>
  24. </head>
  25.  
  26. <body>
  27. <div id="floater">
  28. <p>Image or Text here</p>
  29. </div>
  30. </body>
  31. </html>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.