jQuery的分页插件---pagination.js

 jquery的分页插件pagination.js  下载链接为:http://www.jq22.com/jquery-info5697

 

原理:设置页码样式,数据通过ajax上传当前页码,进行相应处理后传回加载显示在页面上。

 

1.如何使用?

pagination.js是一款较为丰富的分页插件,提供了一些简单接口。使用时,

(1)首先引入所需要的头文件(可在官网中直接下载)

 

 

 注意此时一定要先加载jquery文件。

 

(2)然后在页面中给出容器,设置相应的样式;

(3)根据API进行所需的细节调整;

options(参数配置)

参数默认值说明
pageCount9总页数
totalData0数据总条数
current1当前第几页
showData0每页显示的条数
prevCls'prev'上一页class
nextCls'next'下一页class
prevContent'<'上一页节点内容
nextContent'>'下一页节点内容
activeCls'active'当前页选中状态class名
count3当前选中页前后页数
copingfalse是否开启首页和末页,值为boolean
isHidefalse总页数为0或1时隐藏分页控件
keepShowPNfalse是否一直显示上一页下一页
homePage''首页节点内容,默认为空
endPage''尾页节点内容,默认为空
jumpfalse是否开启跳转到指定页数,值为boolean类型
jumpIptCls'jump-ipt'文本框内容
jumpBtnCls'jump-btn'跳转按钮class
jumpBtn'跳转'跳转按钮文本内容
callbackfunction(){}回调函数,参数"index"为当前页

 

 

api接口

 

方法参数说明
getPageCount()获取总页数
setPageCount(page)page:页数设置总页数
getCurrent()获取当前页
filling()填充数据,参数为

 

2. 实例代码:

前端样式:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <script type="text/javascript" src="jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="jquery.pagination.js"></script>
    <title>nine box</title>
    <style  type="text/css">
        /*table {border-collapse:collapse; margin:50px;text-align:center;}​*/
        table tr {border:none;}

        table.ninetab td{width:50px;height:50px;border:5px  inset blue;}
        table.ninetab td:hover{border:5px solid red;cursor: pointer;}

        #pagination{
            background: #e3e3e3;
            height: 40px;
            line-height: 40px;
            width: 990px;
            margin-top: 20px;
            text-align: right;
        }
        #pagination .active{
            color: #c41929;
            border: 1px solid transparent;
            background: #e3e3e3;
            font-size: 14px;
            padding: 3px 4px;
            margin-right: 10px;
        }
        #pagination a,#pagination span{
            border: 1px solid #cdcdcd;
            background: #fff;
            font-size: 14px;
            padding: 3px 4px;
            color: #000;
            margin-right: 10px;
        }
        #pagination a.jump-btn{
            margin-right: 20px;
            margin-left: 20px;
        }
        #pagination input{
            height: 18px;
            line-height:18px;
            width: 30px;
        }
        #pagetable{
            width:500px;
            height:300px;
            border:1px solid red;
        }

    </style>

</head>
<body>

<div id="pagination"></div>
<div id="pagetable"></div>
<script type="text/javascript">

        var callbackAjax = function(api){
            //获取当前页码
            var current = api.getCurrent();
            var url = 'xxxxx/testpagebar/';//请求数据的地址
            $.post(url,{currentParam :current}, function(data){
          //获得后端数据,显示到页面上
              console.log(data);
          
            $('#pagetable').html(data.result);


        },'json');
    }


    //执行callbackAjax
    $('#pagination').pagination({
        pageCount:20,
        totalData:100,
        showData:5,
        jump:true,
        coping:true,
        count:2,
        homePage:'首页',
        endPage:'末页',
        prevContent:'<上一页',
        nextContent:'下一页>',
        jumpBtn:'确定',
        callback:callbackAjax
    });

    })


</script>
</body>
</html>

 

nodejs后端:

 

var express = require('express');
var router = express.Router();
router.post('/',function(req,res,next){
   var  currentParam = req.body.currentParam;
    console.log(currentParam);
    res.send({"result":currentParam});
    res.end;
})


module.exports = router;

 

 效果图:

 

转载于:https://www.cnblogs.com/Catherine001/p/7298643.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值