无限滚动不起作用?

发布于 2024-12-19 01:00:29 字数 2090 浏览 1 评论 0原文

看起来它不适用于下面的代码,有什么问题吗?它无法工作,也没有错误。

<h1> Infinite Scroll Demo </h1>
    <div id="container">
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
    </div>

    <a id="next" href="demo2.html">next page</a>

    <script src="js/jquery-1.6.1.js"></script>
    <script src="js/jquery.infinitescroll.js"></script>

    <script>

        $('#container').infinitescroll({
            navSelector     : "#next:last",
            nextSelector    : "#next:last",
            itemSelector    : ".includeitem"
        });

     </script>

下面是 demo2.html 的代码,只是将一些 div 内容添加到首页。

    <div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>

<a id="next" href="demo12.html">next page</a>

it looks it doesn't work with code below, what's wrong with it? it cannot work, no error as well.

<h1> Infinite Scroll Demo </h1>
    <div id="container">
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
        <div class="includeitem"> www.gbin1.com </div>
    </div>

    <a id="next" href="demo2.html">next page</a>

    <script src="js/jquery-1.6.1.js"></script>
    <script src="js/jquery.infinitescroll.js"></script>

    <script>

        $('#container').infinitescroll({
            navSelector     : "#next:last",
            nextSelector    : "#next:last",
            itemSelector    : ".includeitem"
        });

     </script>

Below is code for demo2.html, just some div content added to first page.

    <div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>
<div class="includeitem"> www.gbin1.com </div>

<a id="next" href="demo12.html">next page</a>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌酱 2024-12-26 01:00:29

尝试在导航中添加环绕元素,这样两个不同的项目就不会使用相同的 ID。

另外,您不需要:

nextSelector: #next:last

只需使用:

nextSelector: #next

可能是 :last 破坏了它 - 尝试使用 Firebug/web 检查器并查看 $('#next:last') 在您的第一页上返回什么,但很可能是缺少分页容器。

Try adding a wrapping element to your navigation so you aren't using the same ID for two differing items.

Also, you don't need:

nextSelector: #next:last

just use:

nextSelector: #next

It's possible it's the :last breaking it - try using Firebug/web inspector and see what $('#next:last') returns on your first page, but more than likely it's the lack of a pagination container.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文