Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 检查元素是否已完全滚动_Jquery_Web Applications_Mouseevent - Fatal编程技术网

Jquery 检查元素是否已完全滚动

Jquery 检查元素是否已完全滚动,jquery,web-applications,mouseevent,Jquery,Web Applications,Mouseevent,我有以下标记结构 <div class="content-wrapper"> <div class="content">...</div> <div class="content">...</div> <div class="content">...</div> </div> ... ... .

我有以下标记结构

<div class="content-wrapper">
    <div class="content">...</div>
    <div class="content">...</div>
    <div class="content">...</div>
</div>

...
...
...
现在,class
content wrapper
被设置为只有页面总客户区的
80%
高度,并且将
overflow-y
设置为
auto
以便在其主体不适合时有一个滚动条。请注意,内部div
content
可以用于任意次数。所以,问题是如何检查
内容包装器是否已完全滚动?

提示:
想象一个动态加载的新闻提要,当容器被完全滚动时,新内容被自动提取并附加到容器体。

您可以尝试在末尾添加一个没有内容的div,只需给它一些高度。并检查该div是否在视口中。如果是,则表示您已到达滚动的末尾。这里有一个很好的jQuery插件,用于检查元素是否在视图中


希望能有所帮助。

您可以执行以下操作:

var top = $('.content-wrapper').scrollTop();
var height = $('.content-wrapper').height();
if(top==height) {
//load more data
}
另外,我会从滚动高度中减去一些像素,以获得一些分数

document.querySelector('section')。addEventListener('scroll',函数(e){
var isFullyScrolled=this.scrollTop+this.clientHeight>=this.scrollHeight;
document.querySelector('output').textContent=isFullyScrolled;
});
html,主体,部分{
身高:100%;
保证金:0;
}
部分{
溢出:自动;
}
div{
身高:40%;
}
分区:第n个孩子(偶数){
背景:银;
}
输出{
位置:绝对位置;
左:8px;
顶部:8px;
颜色:红色;
字体系列:monospace;
}


滚动
没有帮助。:/请注意,内部
内容
div的数量和大小各不相同。然后发布一些提琴供其使用。也许是时候接受答案了?
var isFullyScrolled = this.scrollTop + this.clientHeight >= this.scrollHeight;