Omer
Omer

Reputation: 5600

Scroll with jQuery

I need to do this in jquery with a little animation (the folowing sentece works):

window.parent.scroll(coord[0], coord[1]);

Does the folowing code to do what I want? because it doesn't, =D

$(window.parent).animate({
    scroll: coord
}, 2000);

Any Ideas?

Thanks

Upvotes: 1

Views: 283

Answers (1)

Tatu Ulmanen
Tatu Ulmanen

Reputation: 124868

You need to animate the scrollTop property:

$(window.parent).animate({
    scrollTop: 'XXpx',
});

Where XX is the amount of pixels from top of the page. scrollLeft works for x-dimension.

Or just use the jQuery.scrollTo plugin: http://demos.flesler.com/jquery/scrollTo/

Upvotes: 3

Related Questions