js分页模板
/**
*参数说明:
*currentPage:当前页数
*countPage:总页数
*changeMethod:执⾏java后台代码的js函数,即是改变分页数据的js函数
*/
function pagination(currentPage,countPage,changeMethod){
var str = "";
var countNum;
//head
if (currentPage == 1) {
str += "<a class=\"pagePre\">⾸页</a>";
str += "<a ><</a>";
}
else {
str += "<a href=\"javascript:void(0)\" onclick=\""+changeMethod+"(1)\"  class=\"pagePre\">⾸页</a>";
str += "<a href=\"javascript:void(0)\" onclick=\""+changeMethod+"("+(currentPage-1)+")\"><</a>";
}
//pageNum
if(currentPage < 4||countPage < 6){
countNum = 1;
}else if(currentPage + 2 > countPage){
countNum = countPage - 4;
}else{
countNum = currentPage - 2;
}
var countPage1 = parseInt(countPage)+1;
var countNum1 = parseInt(countNum);
//body
for(var i = countNum1; i < countPage1; i++){
if(i==currentPage){
str += "<span class=\"cur\">"+i+"</span>";
}else{
str += "<a href=\"javascript:void(0)\" onclick=\""+changeMethod+"("+i+")\">"+i+"</a>";
}
if(i == countNum + 4){
break;
}
}
//end
if (currentPage == countPage) {
str += "<a>></a>";
str += "<a class=\"pagePre\">尾页</a>";
}
else {
str += "<a href=\"javascript:void(0)\" onclick=\""+changeMethod+"("+(currentPage+1)+")\">></a>";
str += "<a href=\"javascript:void(0)\" onclick=\""+changeMethod+"("+(countPage1-1)+")\" class=\"pagePre\">尾页</a>";        }
if(countPage1>2){
$(".page").empty().append(str);
}
}javascript说明

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。