Jquery if $(window) 向下滚动功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25399606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:05:49  来源:igfitidea点击:

Jquery if $(window) scroll down function

jquery

提问by Val Do

hello I need when $(window)is scrolled down with 100%alert something how can I do it?

你好,我需要什么时候$(window)100%警报向下滚动,我该怎么做?

采纳答案by laaposto

Try:

尝试:

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

DEMO

演示

回答by Rick Sanchez

I used something like this once :)

我曾经用过这样的东西:)

   if($(window).scrollTop() + $(window).height() > $(document).height() - 50) {
                       //alert
}

Just play with the numbers, this one is built to pop out the alert just almost before the end of the scroll

只是玩数字,这个数字是为了在滚动结束前弹出警报

回答by Govind

Try this one, When you scroll the page and if the page is reached to bottom, then alert message will get displayed.

试试这个,当您滚动页面时,如果页面到达底部,则会显示警报消息。

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