How to have ellipses clickable to show the next sequence of pagination

雨燕双飞 提交于 2021-02-10 04:29:31

问题


In jQuery DataTables pagination control is displayed like:

1 ... 4 5 6 ... 14

How can I make the ellipses clickable so if it's clicked it will show:

1 ... 7 8 9 ... 14


回答1:


SOLUTION

Use the code below:

$('#example').on('init.dt draw.dt', function(e, settings){
    var api = new $.fn.dataTable.Api(settings);

   $('.dataTables_paginate span a:first + .ellipsis', api.table().container()).replaceWith(
       $('<a class="paginate_button">...</a>').on('click', function(e){ 
           api.page('previous').draw('page'); 
           e.preventDefault();
       })
   ); 

   $('.dataTables_paginate .ellipsis', api.table().container()).replaceWith(
       $('<a  class="paginate_button">...</a>').on('click', function(e){
           api.page('next').draw('page');
           e.preventDefault();
       })
   );        
});

var table = $('#example').DataTable();

where example is ID of your table.

DEMO

See this jsFiddle for code and demonstration.



来源:https://stackoverflow.com/questions/32772041/how-to-have-ellipses-clickable-to-show-the-next-sequence-of-pagination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!