Javascript 麦克斯罗 $(this.hide();//淡出 } if(trnum maxRows){//if tr total rows gt max rows选项 var pagenum=Math.ceil(totalRows/maxRows);//要获取的ceil

Javascript 麦克斯罗 $(this.hide();//淡出 } if(trnum maxRows){//if tr total rows gt max rows选项 var pagenum=Math.ceil(totalRows/maxRows);//要获取的ceil,javascript,jquery,Javascript,Jquery,麦克斯罗 $(this.hide();//淡出 } if(trnum maxRows){//if tr total rows gt max rows选项 var pagenum=Math.ceil(totalRows/maxRows);//要获取的ceil total(rows/maxRows)。。 //页数 对于(变量i=1;i最大行数 $('.pagination li:first child').addClass('active');//将active类添加到第一个li $('.pagin

麦克斯罗 $(this.hide();//淡出 } if(trnum maxRows){//if tr total rows gt max rows选项 var pagenum=Math.ceil(totalRows/maxRows);//要获取的ceil total(rows/maxRows)。。 //页数 对于(变量i=1;i最大行数 $('.pagination li:first child').addClass('active');//将active类添加到第一个li $('.pagination li')。在('click',function(){//上单击每个页面 var pageNum=$(this.attr('data-page');//获取它的编号 var trIndex=0;//重置tr计数器 $('.pagination li').removeClass('active');//从所有li中删除活动类 $(this).addClass('active');//将active类添加到单击的 $(表+'tr:gt(0)')。每个(函数(){//表中的每个tr不是头 trIndex++;///tr索引计数器 //如果tr index gt maxRows*pageNum或lt maxRows*pageNum maxRows在退出时淡出 如果(trIndex>(maxRows*pageNum)| | trIndex
你为什么不使用一个像这样的库来处理这类事情呢?你会得到所有好的表功能,比如排序、过滤、分页等等,因为表是平日创建的,我只能访问前端。这些库提供了对这方面的支持。引用上面的链接:“…支持几乎任何数据源:DOM、JavaScript等等”。为什么不使用类似的库来处理这类内容呢?您将获得所有良好的表功能,如排序、筛选、分页等,因为表是按常规创建的,我只能访问前端。这些库提供了对此的支持。引用上述链接:“…支持几乎任何数据源:DOM、JavaScript等”.很好!但Nalin的答案是第一位。无论如何,谢谢你的帮助!嗨,gaetanoM,我正在使用你的修改和作品,谢谢。问题是,如果你点击“完整页面”链接在html代码的右下角,页码选择器与页面并排显示。如何通过在页面顶部或底部显示一个小图标来修改此行为?@user1265067请查看[]():container fluid,row,col-类以及如何构建网格系统。代码段已更新。请让我知道。效果很好!但Nalin回答是第一个。无论如何,感谢您的帮助!嗨,gaetanoM,我正在使用您的修改,谢谢您。问题是,如果您单击“完整页面”链接在html代码的右下角,页码选择器与页面并排显示。如何通过在页面顶部或底部显示一个小图标来修改此行为?@user1265067请查看[]():container fluid,row,col-classes和如何构建网格系统。代码片段更新。让我知道。这也很好!但是Nalin回答是第一个,无论如何谢谢你的帮助!这也很好!但是Nalin回答是第一个,无论如何谢谢你的帮助!虽然这段代码可以解决这个问题,但是如何以及为什么解决这个问题将是真实的y有助于提高您的帖子质量,并可能导致更多的投票。请记住,您是在将来为读者回答这个问题,而不仅仅是现在提问的人。请在您的回答中添加解释,并说明适用的限制和假设。虽然此代码可能会解决问题,但如何以及为什么is解决了这个问题,这将真正有助于提高你的文章质量,并可能导致更多的投票。请记住,你是在将来为读者回答这个问题,而不仅仅是现在提问的人。请在回答中添加解释,并说明适用的限制和假设。
 $(document).ready(function () {
    getPagination('#Tabla');
});

function getPagination(table) {

  $('#maxRows').on('change', function() {
    $('.pagination').html(''); // reset pagination 
    var trnum = 0; // reset tr counter 
    var maxRows = parseInt($(this).val()); // get Max Rows from select option
    var totalRows = $(table + ' tbody tr').length; // numbers of rows 
    $(table + ' tr:gt(0)').each(function() { // each TR in  table and not the header
      trnum++; // Start Counter 
      if (trnum > maxRows) { // if tr number gt maxRows

        $(this).hide(); // fade it out 
      }
      if (trnum <= maxRows) {
        $(this).show();
      } // else fade in Important in case if it ..
    }); //  was fade out to fade it in 
    if (totalRows > maxRows) { // if tr total rows gt max rows option
      var pagenum = Math.ceil(totalRows / maxRows); // ceil total(rows/maxrows) to get ..  
      //    numbers of pages 
      for (var i = 1; i <= pagenum;) { // for each page append pagination li 
        $('.pagination').append('<li class"wp" data-page="' + i + '">\
                                      <span>' + i++ + '<span class="sr-only">(current)</span></span>\
                                    </li>').show();
      } // end for i 
    } // end if row count > max rows
    $('.pagination li:first-child').addClass('active'); // add active class to the first li 
    $('.pagination li').on('click', function() { // on click each page
      var pageNum = $(this).attr('data-page'); // get it's number
      var trIndex = 0; // reset tr counter
      $('.pagination li').removeClass('active'); // remove active class from all li 
      $(this).addClass('active'); // add active class to the clicked 
      $(table + ' tr:gt(0)').each(function() { // each tr in table not the header
        trIndex++; // tr index counter 
        // if tr index gt maxRows*pageNum or lt maxRows*pageNum-maxRows fade if out
        if (trIndex > (maxRows * pageNum) || trIndex <= ((maxRows * pageNum) - maxRows)) {
          $(this).hide();
        } else {
          $(this).show();
        } //else fade in 
      }); // end of for each tr in table
    }); // end of on click pagination list


    });
}
 $(document).ready(function () {
        $('#maxRows').on('change', function() {
            getPagination('#Tabla',$(this).val());
        });
    getPagination('#Tabla',2); // the no of rows default you want to show
});

function getPagination(table,noRows) {

 $('.pagination').html(''); // reset pagination 
    var trnum = 0; // reset tr counter 
    var maxRows = noRows; // get Max Rows from select option
    var totalRows = $(table + ' tbody tr').length; // numbers of rows 
    $(table + ' tr:gt(0)').each(function() { // each TR in  table and not the header
      trnum++; // Start Counter 
      if (trnum > maxRows) { // if tr number gt maxRows

        $(this).hide(); // fade it out 
      }
      if (trnum <= maxRows) {
        $(this).show();
      } // else fade in Important in case if it ..
    }); //  was fade out to fade it in 
    if (totalRows > maxRows) { // if tr total rows gt max rows option
      var pagenum = Math.ceil(totalRows / maxRows); // ceil total(rows/maxrows) to get ..  
      //    numbers of pages 
      for (var i = 1; i <= pagenum;) { // for each page append pagination li 
        $('.pagination').append('<li class"wp" data-page="' + i + '">\
                                      <span>' + i++ + '<span class="sr-only">(current)</span></span>\
                                    </li>').show();
      } // end for i 
    } // end if row count > max rows
    $('.pagination li:first-child').addClass('active'); // add active class to the first li 
    $('.pagination li').on('click', function() { // on click each page
      var pageNum = $(this).attr('data-page'); // get it's number
      var trIndex = 0; // reset tr counter
      $('.pagination li').removeClass('active'); // remove active class from all li 
      $(this).addClass('active'); // add active class to the clicked 
      $(table + ' tr:gt(0)').each(function() { // each tr in table not the header
        trIndex++; // tr index counter 
        // if tr index gt maxRows*pageNum or lt maxRows*pageNum-maxRows fade if out
        if (trIndex > (maxRows * pageNum) || trIndex <= ((maxRows * pageNum) - maxRows)) {
          $(this).hide();
        } else {
          $(this).show();
        } //else fade in 
      }); // end of for each tr in table
    }); // end of on click pagination list
}
$('#maxRows option:last').prop('selected', true).trigger('change');
<select class="form-control" name="state" id="maxRows">
  <option value="5000">Show ALL Rows</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3" selected>3</option>
</select>
$('#maxRows').on('change', function() {
    // all code here can stay as it is
    // ...
}).trigger('change');