想吧 这个https://www.cnblogs.com/cyrfr/p/6269456.html 分页方式删除 替换下面那个分页
https://www.cnblogs.com/andycja/archive/2011/11/01/2232168.html?tdsourcetag=s_pcqq_aiomsg
分页的函数
代码:
~~~
/*
分页组件博文:http://www.cnblogs.com/andycja/archive/2011/11/01/2232168.html
*/
/*分页*/
function genPaginationHtml(rowsCount, pageSize, curPage, toPage, deviation){
var strPager="";
var pagesCount = Math.floor((rowsCount - 1) / pageSize) + 1;
if(rowsCount > pageSize){
var callPrePage = toPage + "(" + (curPage - 1) + ");";
var callNextPage = toPage + "(" + (curPage + 1) + ");";
if(curPage==1){
strPager += '<a class="pre disable">< 上一页</a>';
}else{
strPager += '<a class="pre" href="javascript:' + callPrePage + '">< 上一页</a>';
}
deviation = !deviation ? 6 : deviation;//当前页居中时左右最大偏移量
var startNum = curPage <= deviation + 1 ? 1 : curPage - deviation;
var endNum = curPage + deviation < pagesCount ? curPage + deviation : pagesCount;
//使总码数固定
if (curPage - startNum < deviation) {
endNum += deviation - (curPage - startNum);
endNum = endNum > pagesCount ? pagesCount : endNum;
}
if (endNum - curPage < deviation) {
startNum -= deviation - (endNum - curPage);
startNum = startNum < 1 ? 1 : startNum;
}
var htmlDot='<span class="dot">...</span>';
for (var i = startNum; i <= endNum; i++){
var htmlNum = "<a class='num' href='javascript:"+toPage+"("+i+");'>"+i+"</a>";
var htmlCurNum = "<span class='current'>"+i+"</span>";
//总是显示第一页和最后一页的页码
if(i == startNum && startNum > 1) {
strPager += "<a class='num' href='javascript:"+toPage+"(1);"+"'>1</a>";
continue;
}
if(i == startNum + 1 && startNum > 1){
strPager += htmlDot;
continue;
}
if(i == endNum - 1 && endNum < pagesCount) {
strPager += htmlDot;
continue;
}
if(i == endNum && endNum < pagesCount){
strPager += "<a class='num' href='javascript:"+toPage+"("+pagesCount+");'>"+pagesCount+"</a>";
continue;
}
strPager += i == curPage ? htmlCurNum : htmlNum;
}
if(curPage==pagesCount){
strPager += '<a class="next disable">下一页 ></a>';
}else{
strPager += '<a class="next" href="javascript:' + callNextPage + '">下一页 ></a>';
}
}
return strPager;
}
~~~
有疑问加站长微信联系(非本文作者)