我使用它来检测滚动到页面的底部.但是如何从页面底部检测距离?
if($(window).scrollTop() + $(window).height() == $(document).height() ) {
.. my ajax here
}
我的意思是我希望该功能在底部为100像素或200像素时执行,而不是页面底部.我该怎么改?
另外:是否可能,如果滚动是最后一个特定的元素(比如说我的大容器),显示加载的内容,可以.
提前致谢
解决方法
var nearToBottom = 100;
if ($(window).scrollTop() + $(window).height() >
$(document).height() - nearToBottom) {
.. my ajax here
}
或滚动到.CONTAINER的底部
if ($(window).scrollTop() + $(window).height() >=
$('.CONTAINER').offset().top + $('.CONTAINER').height() ) {
.. my ajax here
}