符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
jquery动态实现表格分页的方法是利用自带的分页插件jQuery.page.js。
创新互联是一家专业提供陇县企业网站建设,专注与成都网站设计、网站制作、HTML5建站、小程序制作等业务。10年已为陇县众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。
下面是使用方法:
$(".tcdPageCode").createPage({
pageCount:10,
current:1,
backFn:function(p){
//单击回调方法,p是当前页码
}
});
pageCount:总页数
current:当前页
实现分页的tab如下:
div class="tcdPageCode"
span class="disabled"上一页/span
span class="current"1/span
a href="javascript:;" class="tcdNumber"2/a
a href="javascript:;" class="tcdNumber"3/a
a href="javascript:;" class="tcdNumber"4/a
span.../span
a href="javascript:;" class="tcdNumber"6/aa href="javascript:;" class="nextPage"下一页/a/div
实现效果:
先把查询出来的东西放入session对象,在当前页面读取出部分信息,为button按钮添加一个单击事件。查看详细信息也不一定非要在新页面,当前页面添加一个div,做成弹出窗口的效果即可如$("#button1").click(function(){$("body").animate({$(this).append("div style='background:#aaa;position:fixed;left:400px;top:250px;width:400px;height:300px'/div")},500);
这个是一个思路而已,div里面也可以放上其他html标签。弹窗效果有了,然后再把内容添加到这个div就行了,也可以用jquery的jquery ui插件里面的dialog方法弹窗。
,要是在新页面的话设定好样式,重新读取session内容即可。
script language="javascript"
var pagesize=5;//每页显示几条信息
var totalRecord=$("#PageCon li").length;//获取信息的总数
//计算总页数
var totalPages=totalRecord % pagesize == 0 ? totalRecord / pagesize : Math.ceil(totalRecord / pagesize);
$(function(){
$('#PageShowUL').twbsPagination({
totalPages: totalPages,//总页数
visiblePages:7,//显示的页数
version:'1.1',//或1.0 1.1是自动根据当前页动态显示页码
first:"首页",
prev:"下一页",
next:"上一页",
last:"尾页",
onPageClick: function (event,page) {
$("#PageCon li").hide();
$("#PageCon li").slice((page-1)*pagesize,page*pagesize).show();
}
});
});
/script
具体的看这里:
twbs-pagination分页插件的实际应用实例
!DOCTYPE html
html lang="en"
head
meta charset="UTF-8"
meta name="viewport" content="width=device-width, initial-scale=1.0"
meta http-equiv="X-UA-Compatible" content="ie=edge"
titleDocument/title
/head
body
table
tr
th1/th
th2/th
th3/th
th4/th
/tr
/table
table id="result"
tr
td1/td
td2/td
td3/td
td4/td
/tr
tr
td1/td
td2/td
td3/td
td4/td
/tr
tr
td1/td
td2/td
td3/td
td4/td
/tr
tr
td1/td
td2/td
td3/td
td4/td
/tr
/table
div id="barcon"/div
script
window.onload = function () {
goPage(1)
}
function goPage(pno) {
var itable = document.getElementById("result");
var num = itable.rows.length; //表格所有行数(所有记录数)
console.log(num);
var totalPage = 0; //总页数
var pageSize = 3; //每页显示行数
//总共分几页
if (num / pageSize parseInt(num / pageSize)) {
totalPage = parseInt(num / pageSize) + 1;
} else {
totalPage = parseInt(num / pageSize);
}
var currentPage = pno; //当前页数
var startRow = (currentPage - 1) * pageSize + 1; //开始显示的行 31
var endRow = currentPage * pageSize; //结束显示的行 40
endRow = (endRow num) ? num : endRow; //40
//遍历显示数据实现分页
for (var i = 1; i (num + 1); i++) {
var irow = itable.rows[i - 1];
if (i = startRow i = endRow) {
irow.style.display = "table-row";
} else {
irow.style.display = "none";
}
}
var pageEnd = document.getElementById("pageEnd");
var tempStr = "span共" + totalPage + "页/span";
if (currentPage 1) {
tempStr += "span class='btn spanbtn' href=\"#\" onClick=\"goPage(" + (1) + ")\"首页/span";
tempStr += "span class='btn spanbtn' href=\"#\" onClick=\"goPage(" + (currentPage - 1) + ")\"上一页/span"
} else {
tempStr += "span class='btn spanbtn'首页/span";
tempStr += "span class='btn spanbtn'上一页/span";
}
if (totalPage == 1) {
tempStr += "a onclick=\"goPage(" + currentPage + ")\"span class='spanbtn nowpage pageicon'" + currentPage +
"/span/a"
} else if (totalPage == 2 currentPage == 1) {
tempStr += "a onclick=\"goPage(" + currentPage + ")\"span class='spanbtn pageicon nowpage'" + currentPage +
"/span/a" + "a onclick=\"goPage(" + (currentPage + 1) + ")\"span class='spanbtn pageicon'" +
(currentPage + 1) + "/span/a"
} else if (totalPage == 2 currentPage == 2) {
tempStr += "a onclick=\"goPage(" + (currentPage - 1) + ")\"span class='spanbtn pageicon'" + (currentPage -
1) + "/span/a" + "a onclick=\"goPage(" + currentPage + ")\"span class='spanbtn nowpage pageicon'" +
currentPage + "/span/a"
} else if (totalPage = 3 currentPage == 1) {
tempStr += "a onclick=\"goPage(" + currentPage + ")\"span class='spanbtn nowpage pageicon'" + currentPage +
"/span/a" + "a onclick=\"goPage(" + (currentPage + 1) + ")\"span class='spanbtn pageicon'" +
(currentPage + 1) +
"/span/a" + "a onclick=\"goPage(" + (currentPage + 2) + ")\"span class='spanbtn pageicon'" + (
currentPage + 2) +
"/span/a"
} else if (totalPage = 3 currentPage == totalPage) {
tempStr += "a onclick=\"goPage(" + (currentPage - 2) + ")\"span class='spanbtn pageicon'" + (currentPage -
2) +
"/span/a" + "a onclick=\"goPage(" + (currentPage - 1) + ")\"span class='spanbtn pageicon'" +
(currentPage - 1) +
"/span/a" + "a onclick=\"goPage(" + currentPage + ")\"span class='spanbtn nowpage pageicon'" +
currentPage +
"/span/a"
} else {
tempStr += "a onclick=\"goPage(" + (currentPage - 1) + ")\"span class='spanbtn pageicon'" + (currentPage -
1) +
"/span/a" + "a onclick=\"goPage(" + currentPage + ")\"span class='spanbtn nowpage pageicon'" +
currentPage +
"/span/a" + "a onclick=\"goPage(" + (currentPage + 1) + ")\"span class='spanbtn pageicon'" + (
currentPage + 1) +
"/span/a"
}
if (currentPage totalPage) {
tempStr += "span class='btn spanbtn' href=\"#\" onClick=\"goPage(" + (currentPage + 1) + ")\"下一页/span";
tempStr += "span class='btn spanbtn' href=\"#\" onClick=\"goPage(" + (totalPage) + ")\"尾页/span";
} else {
tempStr += "span class='btn spanbtn'下一页/span";
tempStr += "span class='btn spanbtn'尾页/span";
}
document.getElementById("barcon").innerHTML = tempStr;
}
/script
/body
/html
自己修改一下table中元素的CSS样式,分页页码的样式,就能看出来效果了