Scroll inside div with jquery?

落花浮王杯 提交于 2019-12-23 09:09:14

问题


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);
            }


来源:https://stackoverflow.com/questions/2488308/scroll-inside-div-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!