views:

54

answers:

1
+2  Q: 

Scroll with jQuery

Hi.. 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

+3  A: 

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/

Tatu Ulmanen