gpt4 book ai didi

javascript - 如何使用 JQuery 检测用户是否滚动到页面底部?

转载 作者:数据小太阳 更新时间:2023-10-29 04:54:26 24 4
gpt4 key购买 nike

触底后有回调函数吗?

最佳答案

您可以在窗口中以这种方式使用 .scroll() 事件:

$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});

检查 live demo

要检测用户是否在页面下方的 3/4,您可以试试这个

$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - .75*$(document).height()) {
alert("3/4th of bottom!");
}
});

关于javascript - 如何使用 JQuery 检测用户是否滚动到页面底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9697748/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com