我的代码滚动浏览了一系列divs
,每个都称为.container
. 每个.container
都有 100% 的高度,因此用户最终会在页面的下方很远。
.container
现在,一旦用户到达页面底部,我就会尝试滚动回顶部(使用相同的类)。
$('.down').click(function (e) {
var next_container = $(this)
.next(container);
$('html, body')
.animate({
scrollTop: next_container.offset().top
}, 'slow');
});
jQuery 有没有办法检测到用户位于文档的底部,并因此滚动到第一个.container
(而不是下一个)?