写个js 分页玩玩(原创)

2020-12-13 06:05

阅读:510

标签:style   blog   class   c   code   java   

soscw.com,搜素材
ul id="page">
    li class="pagetest">1li>
    li class="pagetest">2li>
    li class="pagetest">3li>
    li class="pagetest">4li>
    li class="pagetest">5li>
    li class="pagetest">6li>
    li class="pagetest">7li>
    li class="pagetest">8li>
    li class="pagetest">9li>
    li class="pagetest">10li>
    li class="pagetest">11li>
    li class="pagetest">12li>
ul>
div id="pageDom">div>
script src="http://code.jquery.com/jquery-latest.js">script>
div class="dibu">    
    script>    
    var pageInfo={PageSize:null,TotalItemCount:null,PageNumber:null,PageCount:null,HasPreviousPage:null,HasNextPage:null,frontPageSize:5,backPageSize:4,pageListDomID:null,pageNumberDomID:null};
    pageInfo.pageListDomID="page";
    pageInfo.pageNumberDomID="pageDom";
    pageInfo.PageSize=2;
    
    GetPageInfo(2);    
    
    function GetPageInfo(pageNumber)
    {    
        $("#"+pageInfo.pageListDomID).children().hide().slice((pageNumber-1)*pageInfo.PageSize,pageNumber*pageInfo.PageSize).show();        
        
        pageInfo.TotalItemCount=$("#"+pageInfo.pageListDomID).children().length;
        pageInfo.PageNumber=pageNumber;
        pageInfo.PageCount=Math.ceil(pageInfo.TotalItemCount/pageInfo.PageSize);
        if(pageInfo.PageNumber>1)
        {
            pageInfo.HasPreviousPage=true;
        }else
        {
            pageInfo.HasPreviousPage=false;
        }    
        if(pageInfo.PageNumberpageInfo.PageCount)
        {
            pageInfo.HasNextPage=true;
        }else
        {
            pageInfo.HasNextPage=false;
        }
        
        updatePage(pageInfo.pageNumberDomID);
    }

    function updatePage(id)
    {        
        $("#"+id).empty();        
        if (pageInfo.HasPreviousPage)
        {
            $("#"+id).append(上一页);              
        }
        for (var i = pageInfo.PageNumber - pageInfo.frontPageSize; i  pageInfo.PageNumber + pageInfo.backPageSize; i++)
        {
            if (i >= 1 && i  pageInfo.PageCount)
            {
                if (pageInfo.PageNumber == i)
                {
                    $("#"+id).append(+i+);
                }
                else
                {
                    $("#"+id).append(+i+);">+i+);                          
                }
            }
        }
        if (pageInfo.HasNextPage)
        {
            $("#"+id).append(下一页);
        }
    }    
    script>        
div>
  
soscw.com,搜素材

 

写个js 分页玩玩(原创),搜素材,soscw.com

写个js 分页玩玩(原创)

标签:style   blog   class   c   code   java   

原文地址:http://www.cnblogs.com/zhudongchang/p/3739543.html


评论


亲,登录后才可以留言!