• 一个比较轻巧好用的js分页插件,可ajax可url


    var pageNav = pageNav || {};
    pageNav.fn = null;
    pageNav.pre = "pre";
    pageNav.next = "next";
    pageNav.nav = function (a, b) {
        if (1 >= b)return this.pn = this.p = 1, this.pHtml2(1);
        b < a && (a = b);
        var c = "";
        1 >= a ? a = 1 : (c += this.pHtml(a - 1, b, pageNav.pre), c += this.pHtml(1, b, "1"));
        this.p = a;
        this.pn = b;
        var d = 2, e = 9 > b ? b : 9;
        7 <= a && (c += "...", d = a - 4, e = a + 4, e = b < e ? b : e);
        for (; d < a; d++)c += this.pHtml(d, b);
        c += this.pHtml2(a);
        for (d = a + 1; d <= e; d++)c += this.pHtml(d, b);
        e < b && (c = c + "..." + this.pHtml(b, b));
        a < b && (c += this.pHtml(a + 1, b, pageNav.next));
        return c
    };
    pageNav.pHtml = function (a, b, c) {
        return" <a href='javascript:pageNav.go(" + a + "," + b + ");' class='pageNum'>" + (c || a) + "</a> "
    };
    pageNav.pHtml2 = function (a) {
        return" <span class='cPageNum'>" + a + "</span> "
    };
    pageNav.go = function (a, b) {
        document.getElementById("pageNav").innerHTML = this.nav(a, b);
        null != this.fn && this.fn(this.p, this.pn)
    };
    /*
     <style>
     .pageNum{border: 1px solid #999;padding:2px 8px;display: inline-block;}
     .cPageNum{font-weight: bold;padding:2px 5px;}
     #pageNav a:hover{text-decoration:none;background: #fff4d8; }
     </style>
     * //$(function(){ //for jquery
     window.onload = (function(){
    
     //optional set
     pageNav.pre="PRE3";
     pageNav.next="NEXT";
    
     //  p:current page number.
     //  pn: page sum.
     pageNav.fn = function(p,pn){
     document.getElementById("test").innerHTML ="Page:"+p+" of "+pn + " pages.";
     //$("#test").text("Page:"+p+" of "+pn + " pages."); //for jquery
     };
    
     //goto the page 3 of 33.
     pageNav.go(3,53);
    
     });*/
    

    官方地址:https://code.google.com/p/page-nav-js-jquery/  

    暗夜之中,才见繁星;危机之下,暗藏转机;事在人为,为者常成。
  • 相关阅读:
    学习使用Markdown
    开发落网电台windows phone 8应用的计划(10)-----收尾
    MyEclipse10安装SVN插件
    HBuilder连接码云
    sqlserver2004数据库备份,在sqlserver2008还原
    fiddler抓包时出现了tunnel to ......443
    Fiddler抓取Android真机上的HTTPS包
    Fiddler证书安装(查看HTTPS)
    Mac安装普元移动开发平台Primeton Mobile_7.2LA
    Mac下安装MySQL、Workbench以及建数据库建表最基础操作
  • 原文地址:https://www.cnblogs.com/zenghansen/p/4623669.html
Copyright © 2020-2023  润新知