【发布时间】:2012-03-30 15:55:23
【问题描述】:
一旦触底,有回调函数吗?
【问题讨论】:
标签: javascript jquery browser scroll
一旦触底,有回调函数吗?
【问题讨论】:
标签: javascript jquery browser scroll
您可以在窗口上以这种方式使用 .scroll() 事件:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
要检测用户是否在页面下方 3/4,您可以试试这个
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - .75*$(document).height()) {
alert("3/4th of bottom!");
}
});
【讨论】:
$(document).height() - 75 更改为 $(document).height() * 0.75 应该可以解决问题。