JQuery fadeIn() on DOM element creation?

How do I create a DOM element in JQuery and fade it in to show up, instead of having it show up immediately?

I try this:

var myDiv = "<div>Hello!</div>"
$("somePlace").after(myDiv).fadeIn('fast');

but this doesn’t work, since the .after(myDiv) makes it popup immediately. Any solutions? Thanks!

$("<div>Hello</div>").hide().appendTo("somePlace").fadeIn("fast");

Add it with a class that is hidden at the start.

<style>
  .hidden {
    display: none;
  }
</style>

<div class="hidden">
  Won't be seen.
</div>


The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   Cross-browser (IE8-) getComputedStyle with Javascript?

Similar Posts