【问题标题】:Can someone help me interpret this code for an Endless Page Script?有人可以帮我解释这个无尽页面脚本的代码吗?
【发布时间】:2018-03-21 19:43:50
【问题描述】:

我想使用这个脚本制作多个无尽的页面,但是我似乎只能创建两个页面。谁能告诉我我做错了什么?

var counter = 0;
$(window).scroll(function() {
  if ($(window).scrollTop() == $(document).height() - $(window).height() && counter < 4) {
    appendData();
  }
});

function appendData() {
  var html = '';
  for (i = 0; i < 1; i++) {
    html += '';

  }
  if (counter < 1)
    $('#myScroll').append('<? include_once 'GNC-10';?>');
  counter++;
  if (counter == 3)
    $('#myScroll').append('<? include_once 'GNC-2';?>');
  counter++;

}

【问题讨论】:

  • 第一次 0. 附加 GNC-10。变为 1. 变为 2. 第二次 2. 变为 3. 附加 GNC-2。变为 4。一旦变为 4 或更多,任何追加都不会再发生。
  • 谢谢!那我怎么加一个加法线,会是这样吗?
  • } if(counter ');计数器++; if(counter > 2) $('#myScroll').append(' include_once 'GNC-10';?>');计数器++; if(counter == 3) $('#myScroll').append(' include_once 'GNC-2';?>');计数器++; }
  • 请使用任何代码编辑您的问题,而不是将其放入 cmets。很难阅读。
  • 哎呀!对此感到抱歉

标签: jquery infinite-scroll


【解决方案1】:
                                                                              var counter=0;
    $(window).scroll(function () {
        if ($(window).scrollTop() == $(document).height() - $(window).height() && counter < 4) {
            appendData();
        }
    });
    function appendData() {
        var html = '';
        for (i = 0; i < 1; i++) {
            html += '';

        }
        if(counter < 1)
        $('#myScroll').append('<? include_once 'GNC-10.php';?>');
        counter++;
        if(counter > 2)
        $('#myScroll').append('<? include_once 'GNC-1.php';?>');
        counter++;
        if(counter == 3)
        $('#myScroll').append('<? include_once 'GNC-2';?>');
        counter++;

         }

【讨论】:

    猜你喜欢
    • 2015-07-14
    • 2016-07-14
    • 2018-07-23
    • 2014-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多