Fading out a div after set time with jQuery

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

Here’s a handy bit of code that I use quite regularly, its particularly useful if your getting a response message from a form to notify the user that there data was sent, or comunicate an error and you want to fade the message out after a set time.

Copy this code and paste it in your HTML
  1. $(document).ready(function(){
  2. setTimeout(function(){
  3. $("div.mydiv").fadeOut("slow", function () {
  4. $("div.mydiv").remove();
  5. });
  7. }, 2000);
  8. });

URL: http://papermashup.com/jquery-fading-a-div-after-a-certain-time/

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.