/**
* [滚动条]
*/
$(window).scroll(function() {
var scrollTop = $(this).scrollTop(); // 滚动条距离顶部的高度
console.log("滚动条距离顶部的高度-->" scrollTop);
var scrollHeight = $(document).height(); // 当前页面的总高度
console.log("当前页面的总高度-->" scrollHeight);
var clientHeight = $(this).height(); // 当前可视的页面高度
console.log("当前可视的页面高度-->" clientHeight);
if (scrollTop clientHeight >= scrollHeight) { // 距离顶部高度 可视高度 >= 文档总高度 即代表滑动到底部
// code...
alert('已经到底了!');
} else if (scrollTop <= 0) {
// code...
alert('已经到顶了!');
}
});
更多专业前端知识,请上 【猿2048】www.mk2048.com