Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
170
rated 0 times [  177] [ 7]  / answers: 1 / hits: 26298  / 15 Years ago, fri, july 17, 2009, 12:00:00

I have the code below working like a charm:



var div = $('#div');
div.html('<div>one line</div><div>another line</div>');
div.slideDown('slow');


But the problem comes when I need to change the content (the number of lines):



div.html('<div>one line replacement</div><div>another line replacement</div><div>third line</div>')


This transition is too fast. How to animate this?


More From » jquery

 Answers
3

You can add an invisible span to the html:



<span class=foo style=display: none>some other lines</span>


And then fade them in:



$(span.foo).fadeIn('slow');




Going by your edit, you may also want to consider:



div.slideUp('slow'); // you may want this to be 'fast'
div.html('some other lines');
div.slideDown('slow');

[#99106] Monday, July 13, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chazw

Total Points: 127
Total Questions: 129
Total Answers: 92

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;