Show a div for couple of seconds and then disappear automatically

user1706511 picture user1706511 · Aug 19, 2013 · Viewed 9.4k times · Source

When a page loads, a div should appear for like 3 seconds and then automatically disappear. I'm having trouble with the code at the moment. I'm using this code below:

jQuery("#infor").delay(6000).fadeOut("slow");

My HTML is:

<div id="infor">
something
</div>

But it doesn't seem to be working. Does anyone have any idea why this code is not working?

Answer

Barbara Laird picture Barbara Laird · Aug 19, 2013

Is your code within a document.ready block?

$( document ).ready(function() {
    $("#infor").delay(3000).fadeOut("slow");
});

It works for me: http://jsfiddle.net/YdU4z/