CLiown
CLiown

Reputation: 13843

jQuery animate .prepend

Rather than simply dumping the HTML into the page I want it to be animated, how can I change the jQuery below to either animate or slide down as the HTML is inserted?

$('.button').click(function() {

j('.tweets ul').prepend(j('.refreshMe ul').html());

});

Upvotes: 7

Views: 9457

Answers (1)

Nick Craver
Nick Craver

Reputation: 630389

You can .hide() the content before doing a .prependTo(), then call .slideDown() on the element, like this:

$('.button').click(function() {
 j('.refreshMe ul > *').clone().hide().prependTo('.tweets ul').slideDown();
});

This does .clone() of the children to move, rather than doing an innerHTML style copy, hides the cloned elements before moving them, then slides them down.

Upvotes: 25

Related Questions