Suppose I use JQuery to do an ajax call, and the result is returned in HTML.
I want to add this result to my current page.
$("#tweets").prepend(result);
result is a string of html code.
This works. However, it just appears. I want it to fadeIn(400). How can I make it fade in?
Make the HTML hidden by default. If you tell the browser to fade in an element that is already shown, it’ll do nothing (which is what you’re experiencing).
For example, you could wrap the
resultHTML in adivtag with the classResponseData. Then, in CSS, you could add this rule:Now, as soon as that data is prepended into the
tweetsarea, it’ll be hidden. Then, yourfadeincall will work as desired.Your Javascript would look something like this: