Home > Web Front-end > JS Tutorial > Scroll the DIV scroll bar to the specified position through JQuery to facilitate automatic positioning_jquery

Scroll the DIV scroll bar to the specified position through JQuery to facilitate automatic positioning_jquery

WBOY
Release: 2016-05-16 16:49:49
Original
1313 people have browsed it

Here is a method to scroll the DIV's scroll bar to the location of its child elements to facilitate automatic positioning.

Copy code The code is as follows:

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-in to achieve the desired effect, it’s very easy to use!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template