Dynamic pagination in Jquery

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

I have this code :



        
7条回答
  •  暖寄归人
    2021-02-06 11:09

    Place this somewhere it is executed when the DOM is ready, but before the click event handlers are added.

    //How many pages do we want?
    elementCount = $('.line-content').size();
    pageCount = Math.ceil(elementCount / pageSize);
    
    //Add the buttons.
    buttons = '';
    for(i=1; i<=pageCount; i++) {
        buttons += '
  • ' + i + '
  • '); } $('#pagin').html(buttons);

    Then you can just leave #pagin empty and the JavaScript will fill it for you:

    Disclaimar: I haven't tested this code.

提交回复
热议问题