[英]How to load more content with ajax when user scrolls to the bottom the of page only once
[英]How to only show a specific number of divs on the page and load more when the user scrolls to the bottom?
有6个div,它们都具有相同的类。 我将如何做到这样,以便仅在页面上显示前3个div,而当用户滚动到页面底部时,则显示其他3个div?
此外,可能并不总是只有6个div。 假设有12个div,当用户滚动到页面底部时,代码仍然需要显示前3个div,并继续显示3个div。
<div class="post">
Lorem
</div>
<div class="post">
Lorem ipsum
</div>
<div class="post">
Lorem ipsum ....
</div>
<div class="post">
Lorem...
</div>
<div class="post">
Loremsdfdsf
</div>
<div class="post">
Lorem.......
</div>
我只能设法找到此http://jscroll.com/,但它要求您在页面底部包含一个href
链接,该链接指向您希望在用户滚动到末尾时显示的文件。
您还可以使用jQuery的便捷方法scrollTop()并使用scroll()捕获滚动事件。 您只需检查滚动是否足够远,如果可以,请加载新内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.