views:

84

answers:

4

For example, when someone clicks on a button.

+4  A: 

You're looking for the delay function:

$(something).delay(5000).fadeOut();    //5,000 milliseconds

In general, you can call setTimeout:

setTimeout(function() {
    //Do things...
}, 5000);
SLaks
+1  A: 

In 1.4 you can use the .delay() function. Here's the documentation for that:

jQuery Docs

Alternately you could look into the native javascript setTimeOut() function.

Alex Mcp
A: 

If you're using the JQuery 1.4+, you could try

$('#myDiv').fadeIn('medium').delay(5000).fadeOut('medium');

You can remove the fadeIn if the div is visible straight away.

keyboardP
+1  A: 

Use the delay function available since 1.4

From the docs: http://api.jquery.com/delay/

$('#foo').fadeIn(400).delay(5000).fadeOut(400);
Eoin