gpt4 book ai didi

jquery - 滚动结束时调用函数

转载 作者:行者123 更新时间:2023-12-01 00:14:28 25 4
gpt4 key购买 nike

我想在滚动到达页面底部时调用特定函数。

这是我使用的代码,但它对我不起作用。没有控制台错误,但仍然无法工作。

$(function() {

var scrollEnded = $.debounce(500, false, function() {

console.log('scroll ended');

alert("ok"); // I will call my function here. Just need an alert.

});

});

最佳答案

试试这个功能

$(function(){
$(window).scroll(function(){
if($(document).height()==$(window).scrollTop()+$(window).height()){
alert('I am at the bottom');
// Here goes your code.
}
});
});

检查这个JSFIDDLE

关于jquery - 滚动结束时调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18693215/

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