兼容IE6+及现代浏览器的简单分页,支持同一页面多个分页。
<link rel="stylesheet" href="css/GB-paging.css">
<script src="js/GB-paging.js"></script>
<div id="gbpaging" class="gb-paging">
gbPaging({
total: 101,
paramName: 'p',
curPage: getPage('p', '#'),
size: 5,
prevText: '<',
nextText: '>',
pageInfo: '<b>{{currentPage}}</b>/<b>{{totalPages}}</b>',
eventType: 'click'
});
<div id="paging1" class="gb-paging"></div>
gbPaging({
eleId: 'paging1',
total: 54,
size: 10,
prevText: false,
nextText: false,
paramName: 'p1',
curPage: getPage('p1', '#'),
pageInfo: false,
eventType: 'click'
});
<div id="paging2" class="gb-paging"></div>
gbPaging({
eleId: 'paging2',
total: 2500,
paramName: 'page',
curPage: getPage('page', '?type=1&name=2&'),
goUrl: '?type=1&name=2&{{n}}'
});
function getPage(pname, other){
var page = window.location.search.replace( other + pname + '=', '') || 1;
return parseInt(page);
}
eleId
分页容器,仅支持ID,默认为: 'gbpaging'total
: 总记录数paramName
: 分页参数名 || 'p'curPage
: 当前页码size
: 每页记录数 || 10prevText
: 上一页文案 || '上一页',值为 false 不显示nextText
: '下一页文案 || '下一页' 值为 false 不显示pageInfo
: 分页信息,{{currentPage}}当前页码,{{totalPages}}总页数 || 当前第{{currentPage}}页/共{{totalPages}}页,值为 false 不显示eventType
: 事件方式,'click' || 'link'goUrl
: 链接URL,'?type=1&name=2&{{n}}' || '',{{n}}为分页参数名+值,如:'p=1'
演示网页排版来自: https://github.com/sofish/typo.css