For the previously written pages, you need to put the passed parameters in the hidden pages during the operation, which is troublesome. We have repackaged the parameters below, if you need it, you can refer to the previously written pages for a long time. However, in addition to uploading pages, some other parameters are also required, in the past, we had to put the passed parameters in the hidden den, and retrieve them during paging. This is troublesome. We have nothing to do today and repackaged them.
Run the Code directly.
Css uses the pagination style in bootstrap
.pagination-lg > li:first-child > a,.pagination-lg > li:first-child > span {border-bottom-left-radius: 6px;border-top-left-radius: 6px;}.pagination-lg > li:last-child > a,.pagination-lg > li:last-child > span {border-top-right-radius: 6px;border-bottom-right-radius: 6px;}.pagination-sm > li > a,.pagination-sm > li > span {padding: 5px 10px;font-size: 12px;}.pagination-sm > li:first-child > a,.pagination-sm > li:first-child > span {border-bottom-left-radius: 3px;border-top-left-radius: 3px;}.pagination-sm > li:last-child > a,.pagination-sm > li:last-child > span {border-top-right-radius: 3px;border-bottom-right-radius: 3px;}.sr-only {position: absolute;width: 1px;height: 1px;padding: 0;margin: -1px;overflow: hidden;clip: rect(0, 0, 0, 0);border: 0;}
Paging code:
(Function ($) {var PageFunc = function PageFunc () {}$. pageFunc = function (Total, PageSize, curPageNum, FunUrl, paramStr) {if (PageSize = "" | PageSize = null | PageSize = undefined) {PageSize = 10;} if (curPageNum = "" | curPageNum = null | curPageNum = undefined) {curPageNum = 1;} var hasParam = true; if (paramStr = "" | paramStr = null | paramStr = undefined) {hasParam = false;} // calculates the total number of pages Total = parseInt (Total); // Total number of records PageSize = parseInt (PageSize); // number of records displayed per page curPageNum = parseInt (curPageNum ); // current page // total number of pages var AllPage = Math. floor (Total/PageSize); if (Total % PageSize! = 0) {AllPage ++;} var navHtml ="
"; If (curPageNum <= 0) curPageNum = 1; if (AllPage> 1) {if (curPageNum! = 1) {// process the homepage connection var home = 1; if (hasParam) {home = home + "," + paramStr;} navHtml + ="
- | <
";}If (curPageNum> 1) {var previous = parseInt (curPageNum)-1); if (hasParam) {previous = previous +", "+ paramStr ;} // process the previous page connection navHtml + ="
- <
";} Else {navHtml + ="
- <
";}Var currint = 5; for (var I = 0; I <= 10; I ++) {// a total of 10 page numbers can be displayed, with the first five, next five if (curPageNum + I-currint)> = 1 & (curPageNum + I-currint) <= AllPage) if (currint = I) {// process navHtml + ="
- "+ CurPageNum +" (current)
";} Else {// General page processing var n = parseInt (curPageNum) + parseInt (I)-parseInt (currint); var nstr = n; if (hasParam) {nstr = nstr + "," + paramStr;} navHtml + ="
- "+ N +"
";}} If (curPageNum <AllPage) {// process the next page Link var next = parseInt (curPageNum) + 1); if (hasParam) {next = next + "," + paramStr;} navHtml + ="
- >
";} Else {navHtml + ="
- >
";} If (curPageNum! = AllPage) {var last = parseInt (AllPage); if (hasParam) {last = last + "," + paramStr;} navHtml + ="
- > |
";}} If (parseInt (AllPage )! = 0) {navHtml + ="
- "+ CurPageNum +"/"+ AllPage +"
";} NavHtml + ="
"; Return navHtml ;};}) (jQuery );
Call method:
Note: The first parameter must be the value of the current page.
function aa(curpage,param1,param2){if (curpage == "" || curpage == null || curpage == undefined) {curpage = 1;}var pagesize = 5;var paramStr="";paramStr=param1+","+param2+";$.post("/appdefult/apporder",{"categoryId":param1,"name":param2,"curpage":curpage,"pagesize":pagesize},function(mydata){ var pageHtml= $.PageFunc(mydata.total, pagesize, curpage, "aa",paramStr);$(".page").html(pageHtml);},"json");}