views:

102

answers:

5

in jquery, how can I show a hidden div, and make it fade in?

+1  A: 
$("selector_for_your_div").fadeIn("slow");

For your edification, documentation for all of the bundled jQuery animation effects / tools is located at:
http://api.jquery.com/category/effects/

See: Jquery Documentation for fadeIn()

Sean Vieira
+7  A: 

Just hide the element initially, ether with .hide() or style="display: none;" (or display: none; in the stylesheet). Then, just call .fadeIn(), like this:

$("#elementID").fadeIn();

The .fadeIn() call automatically removes the display: none when it fades the opacity to 100%, it won't remove visibility: hidden; so don't use this, or you'll have to remove it manually.

Nick Craver
Question: why hide it initially using `.hide()` rather than plain ol' CSS?
dclowd9901
+2  A: 

Use fadeIn():

$('#hiddendiv').fadeIn();

You may change the duration of the fadein:

$('#hiddendiv').fadeIn(1000); // 1000 ms
marapet
+1  A: 

Use fadeIn

$("selector").fadeIn();

Display the matched elements by fading them to opaque.

To hide it back anytime, you can use:

Note that you should initially hide it using css or jquery.

fadeOut

Sarfraz
A: 

selector.fadeIn(speed in miliseconds) is the function your looking for.

If you want the div to retain its space when its not seen use style="opacity:0;" instead of display:none;

Greg Guida