views:

1582

answers:

2

I'm having a problem creating a DOM element, appending it to another element, and having it fade into place.

Obviously, this doesnt seem to work:

$('<div/>').html('hello').appendTo('#parentDiv').fadeIn();

So, what is the proper way?

A: 

Have you tried

$('<div/>').html('hello').appendTo('#parentDiv').hide().fadeIn();
Neil Aitken
+4  A: 

Try:

$("<div>hello</div>").hide().appendTo("#parentDiv").fadeIn();

or alternatively set display none instead of hide().

cletus
dammit! John has made jQuery too easy. I should have realized that.
FluidFoundation