简体   繁体   English

使用javascript或jquery在页面底部执行功能

[英]Execute function on bottom of the page using javascript or jquery

I want to execute the function "nextResults()" if the user has scroll on bottom, using javascript or jquery. 如果用户使用JavaScript或jquery在底部滚动,我想执行功能"nextResults()" My code doesnt work. 我的代码不起作用。

My code: 我的代码:

$(window).scroll(function() {
     if($(window).scrollTop() = $(document).height() - $(window).height()) {
          nextResults();
     }
});

改成:

$(window).scrollTop() === $(document).height() - $(window).height()
$(window).scroll(function() {
     if($(window).scrollTop() == $(document).height() - $(window).height()) {
          nextResults();
     }
});

wrong conditional expression, it should be '==' but yours is '=' 条件表达式错误,应为“ ==”,但您的条件表达式为“ =”

you can test it here, check the browser developer tools console: JSFiddle 您可以在此处进行测试,请检查浏览器开发人员工具控制台: JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM