How to use jqPagination

后端 未结 2 334
情深已故
情深已故 2021-01-14 12:27

Please help me, I don\'t know how to use jqPagination (http://beneverard.github.com/jqPagination/). I would each page which have other content. Ex, page 1,

2条回答
  •  北海茫月
    2021-01-14 12:46

    Right, I can only assume you have code similar to this:

    My first paragraph

    My second paragraph

    My third paragraph

    And you want to show / hide each of your paragraphs in order using jqPaginaton, try the following code:

    $(document).ready(function() {
    
        // hide all but the first of our paragraphs
        $('.some-container p:not(:first)').hide();
    
        $('.pagination').jqPagination({
            max_page    : $('.some-container p').length,
            paged        : function(page) {
    
                // a new 'page' has been requested
    
                // hide all paragraphs
                $('.some-container p').hide();
    
                // but show the one we want
                $($('.some-container p')[page - 1]).show();
    
            }
        });
    
    });​
    

    Take a look at this working jsFiddle example, it demonstrates the use the plugin to be able to show and hide a range of paragraphs. Of course this example could be extended to work with other elements / scenarios too.

    Be sure to comment back on whether this solved your problem.

提交回复
热议问题