Dynamic pagination in Jquery

前端 未结 7 2169
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 10:59

I have this code :



        
7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 11:24

    //Pagination
    	pageSize = 8;
    
    	var pageCount =  $(".line-content").length / pageSize;
        
         for(var i = 0 ; i'+(i+1)+'
  • '); } $("#pagin li").first().find("a").addClass("current") showPage = function(page) { $(".line-content").hide(); $(".line-content").each(function(n) { if (n >= pageSize * (page - 1) && n < pageSize * page) $(this).show(); }); } showPage(1); $("#pagin li a").click(function() { $("#pagin li a").removeClass("current"); $(this).addClass("current"); showPage(parseInt($(this).text())) });
    .current {
      color: green;
    }
    
    #pagin li {
      display: inline-block;
    }
    
    
    1 I have some content
    2 I have some content
    3 I have some content
    4 I have some content
    5 I have some content
    6 I have some content
    7 I have some content
    8 I have some content
    9 I have some content
    10 I have some content
    11 I have some content
    12 I have some content

提交回复
热议问题