David King David King - 1 year ago 120
jQuery Question

jQuery using append with effects

How can I use

with effects like

Having effects on
doesn't seem to work at all, and it give the same result as normal
. No transitions, no animations.

How can I append one div to another, and have a
effect on it?

Answer Source

Having effects on append won't work because the content the browser displays is updated as soon as the div is appended. So, to combine Mark B's and Steerpike's answers:

Style the div you're appending as hidden before you actually append it. You can do it with inline or external CSS script, or just create the div as

<div id="new_div" style="display: none;"> ... </div>

Then you can chain effects to your append (demo):


Or (demo):

var $new = $('#new_div');