直接调用:

th

{

font-size:18px;

}

td

{

font-size:15px;

}

table{

width:600px;

text-align:center;

}

table tr th,td{

height:30px;

line-height:30px;

border:1px solid #ccc;

}

#pageStyle{

display:inline-block;

width:32px;

height:32px;

border:1px solid #CCC;

line-height:32px;

text-align:center;

color:#999;

margin-top:20px;

text-decoration:none;

}

#pageStyle:hover{

background-color:#CCC;

}

#pageStyle .active{

background-color:#0CF;

color:#ffffff;

}

.style1

{

font-size: 12pt;

}

//分頁顯示

$(function () {

var $table = $("table");

var currentPage = 0; //当前页默认值为0

var pageSize = 12; //每一页显示的数目

$table.bind('paging', function () {

$table.find('tbody tr').hide().slice(currentPage * pageSize, (currentPage + 1) * pageSize).show();

});

var sumRows = $table.find('tbody tr').length;

var sumPages = Math.ceil(sumRows / pageSize); //总页数

var $pager = $('

for (var pageIndex = 0; pageIndex < sumPages; pageIndex++) {

$('' + (pageIndex + 1) + '').bind("click", { "newPage": pageIndex }, function (event) {

currentPage = event.data["newPage"];

$table.trigger("paging");

//触发分页函数

}).appendTo($pager);

$pager.append(" ");

}

$pager.insertAfter($table);

$table.trigger("paging");

//默认第一页的a标签效果

var $pagess = $('#pageStyle');

$pagess[0].style.backgroundColor = "#006B00";

$pagess[0].style.color = "#ffffff";

});

//a链接点击变色,再点其他回复原色

function changCss(obj) {

var arr = document.getElementsByTagName("a");

for (var i = 0; i < arr.length; i++) {

if (obj == arr[i]) {       //当前页样式

obj.style.backgroundColor = "#006B00";

obj.style.color = "#ffffff";

}

else {

arr[i].style.color = "";

arr[i].style.backgroundColor = "";

}

}

}

e46f5be31039445d6aede07a14a32845.png

本文来源于网络:查看 >https://www.cnblogs.com/popo1/p/11482407.html

更多推荐