How to make fadeIn preend?

Suppose I use jQuery to call ajax and the result is returned in HTML.

I want to add this result to my current page.

$("#tweets").prepend(result); 

result is a line of html code.

It works. However, it just appears. I want him to disappear (400). How can I make it fade?

+4
source share
1 answer

Make HTML hidden by default. If you tell the browser about the disappearance of an element that is already shown, it will not do anything (this is what you are experiencing).

For example, you can wrap result HTML in a div tag with a ResponseData class. Then in CSS you can add this rule:

 div.ResponseData { display: none; } 

Now, as soon as this data is added to the tweets area, it will be hidden. Then your fadein call will work as desired.

Your Javascript will look something like this:

 $("#tweets").prepend(result); $("div.ResponseData").fadeIn(); 
+5
source

All Articles