yuli chika
yuli chika

Reputation: 9221

How to make 2 animate one by one

How to make 2 animate one by one, first execute scrollTop 1500px, after that execute scrollTop -1500px. Thanks.

$(function(){
    $('#content').animate({
    scrollTop:1500
   }, 300, function(){
    $('#content').animate({
    scrollTop:-1500
   }, 300);
});
});

Upvotes: 1

Views: 549

Answers (2)

ant
ant

Reputation: 22948

Try taking look at http://api.jquery.com/delay/ this might be what you need.

Upvotes: 1

Shadow Wizard
Shadow Wizard

Reputation: 66389

As far as I know, scrollTop can't have negative value so just use top instead:

$(function(){
    $('#content').animate({
       top:1500
    }, 300, function(){
        $('#content').animate({
           top:-1500
        }, 300);
    });
})

Upvotes: 0

Related Questions