Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个具有以下 CSS 属性的 div,以便让它滚动到位:
height: 746px; width: 295px; overflow: auto; margin-bottom: 11px; position: relative;
我需要用 jQuery 做两件事:
我已经尝试使用两者.position()并.offset()获得它现在的位置,但是滚动时都没有更新位置。我究竟做错了什么?
.position()
.offset()
使用 scrollTop 属性
$(element).scrollTop($(element).scrollTop()+100);
使用滚动事件
$(element).scroll(function(){ //检查div的高度和scrollTop的值,这样你就知道你是否在底部,然后做一些代码})