Somebody
Somebody

Reputation: 2779

Move vertically (scroll up) one div within another one

How to move the content of the inner div up, without click any buttons, I mean, like an animation. And is there any way to trigger an event when the animation is done?

Upvotes: 0

Views: 656

Answers (1)

Korvin Szanto
Korvin Szanto

Reputation: 4511

What you need to use is a Callback. Specifically the one built in to .animate.

$('div').animate({top:-50},1000,function() {
    alert('Animation is finished!');
});

Working example: http://jsfiddle.net/koolvin/YGBvb/

Or perhaps you meant something more along the lines of this: http://jsfiddle.net/koolvin/uFwap

$('div').animate({scrollTop:100},1000,function() {
    alert('Animation is finished!');
});

After reviewing your comment, it looks like this is what you want: http://jsfiddle.net/koolvin/uFwap/17/

Upvotes: 2

Related Questions