Saturday, September 16, 2023
HomeCSSjavascript - just how to make this pagination perpage?

javascript – just how to make this pagination perpage?


require assistance for making pagination
ı take this code yet this code not making index/page/1 page/2 … this code making inpage pagination.
just how to make perpage pagination?
sorry my bad english.

heres my code

… … … … … … … … … … … … … … … … … … … … … … … … … … … … …

 < pre > < code >. feature getPageList( totalPages, web page, maxLength)<{
feature array( begin, end) {
return Array.from( Selection (end -begin+ 1),
( _, i)= > i+ begin);} var sideWidth => maxLength < 9? 1
: 2;.
var leftWidth = (maxLength < - sideWidth * 2- 3) > > 1;. var rightWidth=( maxLength - sideWidth * 2 -3)
> > 1;. if (totalPages < = maxLength) >> {return array( 1, totalPages );.
} if( web page = totalPages- sideWidth
- 1- rightWidth ){return array (1, sideWidth).
concat( 0, array( totalPages - sideWidth - 1 - rightWidth - leftWidth, totalPages));
.

} return array( 1, sideWidth). concat (0, array (web page- leftWidth, web page+ rightWidth), 0, array( totalPages - sideWidth + 1, totalPages));.
}

$( feature() {
var numberOfItems = $(". list-container. vid-list"). size;.
var limitPerPage = 10;.
var totalPages = Math.ceil( numberOfItems/ limitPerPage);.
var paginationSize = 7;.
var currentPage;.

feature showPage( whichPage) {
if( whichPage < < 1|| whichPage > > totalPages) return incorrect.

currentPage = whichPage;.

$(". list-container. vid-list"). conceal(). piece(( currentPage - 1) * limitPerPage, currentPage * limitPerPage). program();.

$(". pagination li"). piece( 1, -1). eliminate();.

getPageList( totalPages, currentPage, paginationSize). forEach( product => > {
$("<< li>>"). addClass(" page-item"). addClass( product? "current-page": "dots")
. toggleClass(" energetic", product === currentPage). append($("<< a>>"). addClass(" page-link")
. attr( {href: "javascript: gap( 0 )"} ). message( product|| "...")). insertBefore(". next-page");.
} );.
$(". previous-page"). toggleClass(" disable", currentPage === 1);.
$(". next-page"). toggleClass(" disable", currentPage === totalPages);.
return real;.
}

$(". pagination"). append(.
$("<< li>>"). addClass(" page-item"). addClass(" previous-page"). append($("<< a>>"). addClass(" page-link"). attr( {href: "javascript: gap( 0 )"} ). message(" Prev")),.
$("<< li>>"). addClass(" page-item"). addClass(" next-page"). append($("<< a>>"). addClass(" page-link"). attr( {href: "javascript: gap( 0 )"} ). message(" Following")).
);.

$(". card-content"). program();.
showPage( 1 );.

$( paper). on(" click", ". pagination li.current-page: not(. energetic)", feature() {
return showPage(+$( this). message());.
} );.

$(". next-page"). on(" click", feature() {
return showPage( currentPage + 1);.
} );.

$(". previous-page"). on(" click", feature() {
return showPage( currentPage - 1);.
} );.
} );.
< .

ı require to perpage pagination

RELATED ARTICLES

Most Popular

Recent Comments