该分页插件只展示当前数据,如果前台分页需要把所有数据切割展示才能实现的前台分页

使用前需要引入font-awesome  和分页插件js(在最下面)

拷贝直接用即可实现,替换一下数据 

1 前台分页情况(后台分页下次再分享)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./font-awesome/css/font-awesome.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="simple.jquery.page.js"></script>
<style>
/**分页相关**/
/*.simple-page-pre-wrap > .wrap-table td:first-child , .simple-page-pre-wrap > .wrap-table th:first-child {*/
/*padding-left: 10px;*/
/*}*/
/*.simple-page-pre-wrap > .wrap-table td:last-child , .simple-page-pre-wrap > .wrap-table th:last-child {*/
/*padding-right: 10px;*/
/*}*/
.simple-page {
display: block;
width: 100%;
min-width: 600px;
text-align: right;
line-height: 40px;
margin-top: 10px;
}
.pre-page-icon {
font-size: 20px;
vertical-align: text-bottom;
padding: 0 10px;
color: #333;
}
.next-page-icon {
font-size: 20px;
vertical-align: text-bottom;
padding: 0 10px;
color: #333;
}
.tcdNumber {
min-width: 20px;
display: inline-block;
text-align: center;
line-height: 20px;
padding: 0 3px;
color: #333;
}
.current {
min-width: 20px;
display: inline-block;
text-align: center;
line-height: 20px;
border-radius: 10px;
background-color: #079cda;
padding: 0 3px;
color: #fff;
}
.page-input {
display: inline-block!important;
height: 20px!important;
width: 2.5em!important;
margin: 0 5px 0 10px!important;
text-align: center!important;
outline: none!important;
vertical-align: text-bottom;
color: #131313;
font-size: 13px;
border: 1px solid #9d9d9d;
}
.page-jump-btn {
padding: 5px;
color: #333;
}
.simple-page-loading {
display: none;
color:#666;
margin-right: 10px;
}
.simple-page-loading > i {
margin-right: 10px;
}
.simple-page-pre-wrap {
position: relative;
}
.no-simple-page > .simple-page-pre-wrap > .simplePagePre,
.no-simple-page > .simple-page-pre-wrap > .simplePageNext {
display: none !important;
}
.simplePagePre,.simplePageNext {
display: inline-block;
position: absolute;
top: 0;
width: 46px;
height: 100%;
transition: all .3s;
opacity: 0;
}
.simplePagePre:hover,.simplePageNext:hover {
opacity: .8;
}
.simplePagePre::before,.simplePageNext::before {
content: '\f104';
font: normal normal normal 14px/1 FontAwesome;
font-size: 60px;
line-height: 80px;
text-align: center;
color:#fff;
position: absolute;
top: 50%;
cursor: pointer;
margin-top: -40px;
width: 100%;
background-color: rgba(0,0,0,.3);
}
.simplePagePre {
left: -20px;
}
.simplePageNext {
right: -20px;
}
.simplePageNext:hover {

}
.simplePagePre::before {
border-radius: 0 4px 4px 0;
}
.simplePageNext::before {
content: '\f105';
border-radius: 4px 0 0 4px;
}

</style>
</head>
<body>
<ul class="all" >
</ul>
<div , age:'18'},

]; //后台得到的数据
var html='';
function list(k,arr) {
var arrReal=arr.slice((k*pageSize-pageSize),k*pageSize); // 每一页展示的数据
for(var i in arrReal){
html+='<li>'+arrReal[i].name+'</li>'
}
$('.all').append(html);
html=''
}
list(1,arr1);
$('#ruleExamine_hq').createPage({
current:1,
pageCount:Math.ceil(arr1.length/pageSize),
backFn:function (k) {
$('.all').children('li').remove();
list(k,arr1)
},
isJump:true
})
</script>
</body>
</html>
//simple.jquery.page.js  插件代码
(function($){
var ms = {
init:function(obj,args){
return (function(){
ms.fillHtml(obj,args);
ms.bindEvent(obj,args);
})();
},
//填充html
fillHtml:function(obj,args){
return (function(){
obj.empty();
if(!obj.hasClass('simple-page')){
obj.addClass('simple-page');
}
if(obj.prev().hasClass('wrap-table')){
if(!obj.prev().hasClass('simple-page-pre-wrap')){
obj.prev().wrap('<div class="simple-page-pre-wrap"></div>');
obj.prev().prepend('<span class="simplePagePre"></span>');
obj.prev().append('<span class="simplePageNext"></span>');
}
}
obj.append('<span ){
args.backFn(current);
}
}
});
}
})();
}
};
$.fn.createPage = function(options){
var args = $.extend({
pageCount : 10,
current : 1,
backFn : function(){}
},options);
ms.init(this,args);
}
})(jQuery);

相关文章: