创建自定义分页

问题描述

大家好,我在一个报价网站上工作。我是 JavaScript 的新手。我已经返回了一些报价。

我的 JavaScript

const status = [
  { status: "Do what is right not what is easy." },{ status: "hey there,WhatsApp is using me."},{ status: "Too Busy" },{ status: "Only you can give me that feeling." },{ status: "I had a horribly busy day in converting oxygen into carbon dioxide" },{ status: "Be yourself; everyone else is already taken" },{ status: "Your attitude may hurt me,But main can Kill You!!"},{ status: "love is Blind,be careful." },{ status: "'SUCCESS' is depend on U." },{ status: "If you love someone set it free." },{ status: "love is sweet,When it's new. But it is sweeter when it's true." },{ status: "Where there is love,there is life." },{ status: "Not always 'Available' try your luck.." },{ status: "I am not changed it's just I grew up and you should try too." },{ status: "The biggest slap to your enemies is your success." },{ status: "Born to express,not to impress."},];

我使用“状态”这个词只是为了我自己。我想要一个自定义分页,这样一个页面应该只包含 5 个引号。

虽然我的朋友给了我 JavaScript 但它太难理解了(对我来说!!)。因此,如果有人能找到任何错误、任何额外的代码或任何不同的 JavaScript,请帮忙。

朋友的 JavaScript

$(function() {
//(function(name) {
//  var container = $('#pagination-' + name);
//  var sources = function() {
//    var result = [];
//    for (var i = 1; i < 196; i++) {
//      result.push(i);
//    }
//    return result;
//  }();
//  console.log(sources)
//  var options = {
//    dataSource: sources,//    callback: function(response,pagination) {
//      window.console && console.log(response,pagination);
//      var dataHtml = '<ul>';
//      $.each(response,function(index,item) {
//        dataHtml += '<li>' + item + '</li>';
//      });
//      dataHtml += '</ul>';
//      container.prev().html(dataHtml);
//    }
//  };
//  $.pagination(container,options);
//  container.addHook('beforeInit',function() {
//    window.console && console.log('beforeInit...');
//  });
//  container.pagination(options);
//  container.addHook('beforePageOnClick',function() {
//    window.console && console.log('beforePageOnClick...');
//    return false
//  });
//})('demo1');
  (function(name) {
    var container = $('#pagination-' + name);
    container.pagination({
      dataSource: 'https://api.flickr.com/services/Feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?',locator: 'items',totalNumber: 50,pageSize: 2,showPageNumbers: true,showPrevIoUs: true,showNext: true,showNavigator: true,showFirstOnEllipsisShow: true,showLastOnEllipsisShow: true,ajax: {
        beforeSend: function() {
          container.prev().html('Loading data from flickr.com ...');
        }
      },callback: function(response,pagination) {
        window.console && console.log(22,response,pagination);
        var dataHtml = '<ul>';
        $.each(response,item) {
          dataHtml += '<li>' + item.title + '</li>';
        });
        dataHtml += '</ul>';
        container.prev().html(dataHtml);
      }
    })
  })('demo2');
})

任何一位 JavaScript 专家能否让这个 JavaScript 变得如此动态,以至于每个引用都应该创建一个 <div><p></p></div> 并粘贴到其中。

我的 HTML

<div class="allStatus">
  <div class="latestatus">
    <p class="copytxt"></p>
  </div>
</div>

我需要将引号放在:

<div class="latestatus"><p class="copytxt"></p></div>

感谢那些提前回答的人。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)