Using JQuery to scroll divs to the specified location for easy automatic positioning
- 2020-03-30 02:51:40
- OfStack
There is a way to scroll a DIV's scroll bar to its child elements for automatic positioning.
You don't need any JQuery plug-ins to achieve the desired effect, very useful!
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!