Using JQuery to scroll divs to the specified location for easy automatic positioning


There is a way to scroll a DIV’s scroll bar to its child elements for automatic positioning.


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

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

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

You don’t need any JQuery plug-ins to achieve the desired effect, very useful!