This article mainly introduces the information shared by jQuery front-end paging examples. For more information, refer to the html string of a navigation bar returned in the background when paging is performed, in fact, js is also well implemented at the front end.
Call the pager method and enter a parameter to return an html string of the navigation bar. The method is relatively simple.
The Code is as follows:
/**
* PageSize, number of entries displayed per page
* PageIndex, current page number
* Total pageCount pages
* Url Connection address
* Example of pager (10, 1, 5, 'index') Usage
*/
Function pager (pageSize, pageIndex, pageCount, url ){
Var intPage = 7; // Number Display
Var intBeginPage = 0; // number of start pages
Var intEndPage = 0; // The number of ending pages
Var intCrossPage = parseInt (intPage/2); // displayed number
Var strPage ="
"+ PageIndex +"/"+ pageCount +" page per page "+ pageSize + ";
If (pageIndex> 1 ){
StrPage = strPage + "Homepage ";
StrPage = strPage + "Previous Page ";
}
If (pageCount> intPage) {// the total number of pages is greater than the number of pages displayed on the page
If (pageIndex> pageCount-intCrossPage) {// current page number> total page number-3
IntBeginPage = pageCount-intPage + 1;
IntEndPage = pageCount;
}
Else {
If (pageIndex <= intPage-intCrossPage ){
IntBeginPage = 1;
IntEndPage = intPage;
}
Else {
IntBeginPage = pageIndex-intCrossPage;
IntEndPage = pageIndex + intCrossPage;
}
}
} Else {
IntBeginPage = 1;
IntEndPage = pageCount;
}
If (pageCount> 0 ){
For (var I = intBeginPage; I <= intEndPage; I ++ ){
{
If (I = pageIndex) {// current page
StrPage = strPage + "" + I + "";
}
Else {
StrPage = strPage + "" + I + "";
}
}
}
}
If (pageIndex <pageCount ){
StrPage = strPage + "next page ";
StrPage = strPage + "last page ";
}
Return strPage +"
";
}
Try this method