jquery多个html分页显示,基于jquery封装的一个js分页

(function ($) {

var PageFunc = function PageFunc() { }

$.PageFunc = function (Total, PageSize, curPageNum, FunUrl) {

if (PageSize == "" || PageSize == null || PageSize == undefined) {

PageSize = 10;

}

if (curPageNum == "" || curPageNum == null || curPageNum == undefined) {

curPageNum = 1;

}

//计算总页数

Total = parseInt(Total); //总记录数

PageSize = parseInt(PageSize); //每页显示数

curPageNum = parseInt(curPageNum); //当前页

//总页数

var AllPage = Math.floor(Total / PageSize);

if (Total % PageSize != 0) {

AllPage++;

}

var navHtml = "";

if (curPageNum <= 0)

curPageNum = 1;

if (AllPage > 1) {

if (curPageNum != 1) {

//处理首页连接

navHtml += "|<  ";

}

if (curPageNum > 1) {

//处理上一页的连接

navHtml += "<<  ";

}

else {

navHtml += "<<  ";

}

var currint = 5;

for (var i = 0; i <= 10; i++) {

//一共最多显示10个页码,前面5个,后面5个

if ((curPageNum + i - currint) >= 1 && (curPageNum + i - currint) <= AllPage)

if (currint == i) {

//当前页处理

navHtml += "[" + curPageNum + "]  ";

}

else {

//一般页处理

var n = curPageNum + i - currint;

navHtml += "" + n + "  ";

}

}

if (curPageNum < AllPage) {

//处理下一页的链接

navHtml += ">>  ";

}

else {

navHtml += ">>  ";

}

if (curPageNum != AllPage) {

navHtml += ">| &nbsp";

}

}

navHtml += "[" + curPageNum + "/" + AllPage + "]  ";

return navHtml;

};

})(jQuery);

下边是调用方法:

function QueryList(curpage) {

if (curpage == "" || curpage == null || curpage == undefined) {

curpage = 1;

}

var pagesize = 10;

var Countys = $("#Countys").val(); //县

var enddate = $("#enddate").val(); //结束时间

var begindate = $("#begindate").val(); //开始时间

$.ajax({

url: "",

type: "POST",

data: { "Countys": Countys, "enddate": enddate, "begindate": begindate, "curpage": curpage, "pagesize": pagesize },

dataType: "json",

error: function (xhr, status, errMsg) { window.location.href = "/CommonError/index/" + errMsg.code + "?txt=" + errMsg.msg; },

success: function (mydata) {

var str = "";

$.each(mydata.Tdata, function (i, item) {

str += "

"

str += "

" + $.FormatDateTime(item.ControlBeginTime, false) + "";

str += "

" + $.FormatDateTime(item.ControlEndTime, false) + "";

str += "

" + item.Name + "";

str += "

" + item.PlateNumber + "";

str += "

" + item.ControlDept + "";

if (item.IsAll == "0") {

str += "

全县布控";

}

else {

str += "

按卡口点布控";

}

str += "

" + item.IsAll == "0" ? "全县布控" : "按卡口点布控" + "";

str += "

修改";

str += "

删除";

str += "

详细";

str + "

";

});

$("#srh_rslt tbody").html(str);

$(".pagination").html($.PageFunc(mydata.total, pagesize, curpage, "QueryList"));

}

});

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值