Scroll inside div with jquery?

2019-06-18 06:00发布

问题:

If I have a div that is overflowing, is there a way I could call a jquery function to scroll it down 60px or something?

回答1:

Yes you can use ScrollTo plugin.

UPDATE Seems like link is broken now. New link here



回答2:

Or, simply use the scrollTop() jQuery API call.



回答3:

mine is going like this:

            var offset = item.position().top;
            if (offset < 0 || offset > parent.height()) {
                if (offset < 0)
                    offset = parent.scrollTop() + offset;
                parent.animate({ scrollTop: offset }, 300);
            }