我一直试图检测用户滚动到底部的时间
我有以下代码。
if ($(window).scrollTop() == ($(document).innerHeight() - $(window).height())){
alert('22')
}
这里的问题是,$(window).height()返回与$(document).height()相同的值,它比实际的窗口视图端口大。
我的屏幕结果大约是1280像素。
但$(document).height返回1670个东西,所以是$(window).height()。
所以document.height - window.height总是0
我做错了吗?
我正在使用Mac OSx Chrome。
由于
////////////////////////
window.innerHeight和document.height修正了Sushil建议的问题
答案 0 :(得分:1)
这应该有用;
$(window).scroll(function()
{
if($(window).scrollTop() == $(document).height() - $(window).height())
{
}
});
答案 1 :(得分:0)
$(window).scroll(function () {
if($(window).scrollTop()+ $(window).height() >( $(".photo").offset().top +$(".photo").outerHeight()))
{
//YOUR CODE
}
});