如何使用jqPagination [英] How to use jqPagination

查看:123
本文介绍了如何使用jqPagination的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我不知道如何使用 jqPagination ( http: //beneverard.github.com/jqPagination/).我希望每个页面都有其他内容.例如,第1页,内容是一个段落,第2页是其他段落.而且我不想单击显示/隐藏"来显示内容.

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, the content is a paragraph, page 2 is other paragraph. And I don't want click show/hide to show the content.

谢谢!

推荐答案

对,我只能假定您具有与此类似的代码:

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

<div class="some-container">
    <p>My first paragraph</p>
    <p>My second paragraph</p>
    <p>My third paragraph</p>
</div>

<div class="pagination">
    <a href="#" class="first" data-action="first">&laquo;</a>
    <a href="#" class="previous" data-action="previous">&lsaquo;</a>               
    <input type="text" readonly="readonly" />
    <a href="#" class="next" data-action="next">&rsaquo;</a>
    <a href="#" class="last" data-action="last">&raquo;</a>
</div>

您想使用jqPaginaton按顺序显示/隐藏每个段落,请尝试以下代码:

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();

        }
    });

});​

看看这个工作jsFiddle示例,它演示了使用该插件能够显示和隐藏范围的段落.当然,可以将此示例扩展为与其他元素/方案一起使用.

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.

这篇关于如何使用jqPagination的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆