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.
这是检测用户是否滚动到底部的代码。
$(window).scroll(function() { var distance = $(window).scrollTop() -$(document).height() + $(window).height(); console.log(distance); });
当我重新加载网络浏览器(chrome)时,窗口滚动到底部,chrome中的“距离”值为0或-1。我不知道为什么会这样;
将值转换为整数值,如下所示$(document).height(),$(window).height()
$(document).height()
$(window).height()
parseInt($(document).height()); parseInt($(window).height());