zoukankan      html  css  js  c++  java
  • 分页

    function page(n,s) {
    $("#pageNo2").val(n);
    $("#pageSize").val(s);
    $("#searchForm").submit();
    return false;
    }
    function jump_to(obj){
    var $autopbn = $("#autopbn");
    var totalpage = parseInt($autopbn.attr("totalpage"));
    var num =parseInt(obj);
    if(num<1)num=1;
    if(num>totalpage)num=totalpage;
    $("#pageIndex").val(num);
    page(num);
    }
    (function (){
    var $borspan = $(".borspan");
    var $autopbn = $("#autopbn");
    var recordnum = parseInt($autopbn.attr("recordnum"));
    var curpage = parseInt($autopbn.attr("curpage"));
    var totalpage = parseInt($autopbn.attr("totalpage"));
    //导航标签的个数,只考虑奇数
    var pagenavnum = 5;
    //borspan分页导航栏
    getPagenav();

    function getPageNumberStr(i,pageIndex) {
    var $obj = null;
    if (i == pageIndex){
    $obj = $("<strong>"+pageIndex+"</strong>");
    }else{
    $obj = $("<a href='javascript:jump_to("+i+");'>"+i+"</a>");
    }
    return $obj;
    }
    function getPagenav() {
    //上一页,下一页,跳转节点
    var $pageinfo = $("<cite>共"+recordnum+"条/"+totalpage+"页&nbsp;</cite>");
    var $prev = $("<a href='javascript:jump_to("+(curpage-1)+");'>&nbsp;上一页»&nbsp;</a>");
    var $next = $("<a href='javascript:jump_to("+(curpage+1)+");'>&nbsp;下一页»&nbsp;</a>");
    var $custompage = $("<input type="text" class="page_in" id="destoon_pageno" value='' onkeydown='if(event.keyCode==13){jump_to(this.value);}' type='text'>" +
    "" +
    "<input type="button" class="page_btn" value="GO" onclick="jump_to($('#destoon_pageno').val());">");
    //上一页标签
    if(curpage>1){
    $borspan.append($prev);
    }
    //排除1..34567情况;例如pagenavnum:5,totalpage:6
    if(totalpage <= pagenavnum+1){
    for (var j = 1; j <= totalpage; j++){
    $borspan.append(getPageNumberStr( j, curpage));
    }
    }else{
    //只考虑pagenavnum为奇数的情况,比如为5
    var autopagenum = (pagenavnum+1)/2;
    //左右两边页码,理论值
    var minpage = curpage - (autopagenum - 1);//-1
    var maxpage = curpage + (autopagenum - 1);//3
    //如果当前项导航块左边>2,并且右边< autopagenum-1
    if(minpage > 2 && maxpage < (totalpage-1)){
    $borspan.append("<a href='javascript:jump_to(1);'>1..</a>");
    for (var j = minpage; j <= maxpage; j++){
    $borspan.append(getPageNumberStr( j, curpage));
    }
    $borspan.append("<a href='javascript:jump_to("+totalpage+");'>.."+totalpage+"</a>");
    }else if(minpage < 3){//如果当前项导航块左边<=2,全部为eg:12345 ..n
    for (var j = 1; j <= pagenavnum; j++){
    $borspan.append(getPageNumberStr( j, curpage));
    }
    $borspan.append("<a href='javascript:jump_to("+totalpage+");'>.. "+totalpage+"</a>");
    }else if(maxpage >= (totalpage-1)){//如果当前项导航块右边>
    $borspan.append("<a href='javascript:jump_to(1);'>1 ..</a>");
    for (var j =(totalpage-pagenavnum+1); j <= totalpage; j++){
    $borspan.append(getPageNumberStr( j, curpage));
    }
    }
    }
    //下一页标签
    if(curpage<totalpage){
    $borspan.append($next);
    }

    //头部分页信息详情
    $borspan.append($pageinfo);
    //尾部跳转
    $borspan.append($custompage);

    }
    })()

    <div class="borspan" >
    <a id="autopbn" href="javascript:;"style="display:none" recordnum="${page.count}" curpage="${page.pageNo}" totalpage="${page.last}"></a>
    </div>



  • 相关阅读:
    undefined vs. null
    Callback()
    python基础----元类metaclass
    python基础----__next__和__iter__实现迭代器协议
    python基础----析构函数__del__
    python基础----__slots__方法、__call__方法
    python基础----实现上下文管理协议__enter__和__exit__
    python基础----__setitem__,__getitem,__delitem__
    python基础----isinstance(obj,cls)和issubclass(sub,super)、反射、__setattr__,__delattr__,__getattr__、二次加工标准类型(包装)
    python基础----特性(property)、静态方法(staticmethod)、类方法(classmethod)、__str__的用法
  • 原文地址:https://www.cnblogs.com/gtbky/p/9006808.html
Copyright © 2011-2022 走看看