我有一个对表进行分页的代码,但是我试图在表上添加省略号...,以便它将变为1 2 3 ... 15,而不是列出所有15页。我该如何实现?
function RowPaging(numPerPage) {
$('.tabledata').each(function () {
var currentPage = 0;
var $table = $(this);
$table.bind('repaginate', function () {
$table.find('tbody tr').hide().slice(currentPage * numPerPage, (currentPage + 1) * numPerPage).show();
});
$table.trigger('repaginate');
var numRows = $table.find('tbody tr').length;
var numPages = Math.ceil(numRows / numPerPage);
var $pager = $('<div class="pager"></div>');
for (var page = 0; page < numPages; page++) {
$('<span class="page-number"></span>').text(page + 1).bind('click', {
newPage: page
}, function (event) {
currentPage = event.data['newPage'];
$table.trigger('repaginate');
$(this).addClass('active').siblings().removeClass('active');
}).appendTo($pager).addClass('clickable');
}
$pager.insertAfter($table).find('span.page-number:first').addClass('active');
});
}