views:

185

answers:

3

I have a big table with vertical scroll bar. I would like to scroll to a specific line in this table using jQuery/Javascript.

Should I look for plug-ins for this task, or there are built-in methods ?

Here is a little example to play with.

Thanks a lot !

+5  A: 

I like this one: http://flesler.blogspot.com/2007/10/jqueryscrollto.html

See the demo: http://demos.flesler.com/jquery/scrollTo/

baloo
yes, this is a great plugin. look no further.
mkoryak
Nice, this is cool :)
medopal
An entire plugin for such a simple task?
J-P
@J-P well it got easing and some other convenient options
baloo
The OP didn't ask for all of that though. What the OP wants is actually incredibly simple.
J-P
+1  A: 

I've always found the jQuery scrollTo plugin to be very useful for this. Play with the demos to see if it's for you.

nickf
+6  A: 

Dead simple. No plugins needed.

var container = $('div'),
    scrollTo = $('#row_8');

container.scrollTop(
    scrollTo.offset().top - container.offset().top
);

// Or you can animate the scrolling:
container.animate({
    scrollTop: scrollTo.offset().top - container.offset().top
});​

Documentation for scrollTop.

J-P
+1 for the simplicity
baloo
Thanks ! Looks really very simple ! I'll try that !
Misha Moroshko
When scrolling several times, the difference may be negative. Look here: http://jsfiddle.net/eMJpA/. How would you fix this ?
Misha Moroshko
@Misha, this should work: http://jsfiddle.net/DLKNp/
J-P
Thanks a lot !!!
Misha Moroshko