Scroll inside div with jquery?

2019-06-18 05:50发布

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?

3条回答
一纸荒年 Trace。
2楼-- · 2019-06-18 06:04

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);
            }
查看更多
劳资没心,怎么记你
3楼-- · 2019-06-18 06:08

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

查看更多
相关推荐>>
4楼-- · 2019-06-18 06:14

Yes you can use ScrollTo plugin.

UPDATE Seems like link is broken now. New link here

查看更多
登录 后发表回答