请帮助我,我不知道如何使用 jqPagination ( http://beneverard.github.com/jqPagination/ )。我希望每个页面都有其他内容。例如,第 1 页,内容是一个段落,第 2 页是其他段落。我不想点击显示/隐藏来显示内容。
谢谢!
最佳答案
对,我只能假设您有与此类似的代码:
<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">«</a>
<a href="#" class="previous" data-action="previous">‹</a>
<input type="text" readonly="readonly" />
<a href="#" class="next" data-action="next">›</a>
<a href="#" class="last" data-action="last">»</a>
</div>
并且您想使用 jqPaginaton 按顺序显示/隐藏每个段落,请尝试以下代码:
$(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();
}
});
});
看看这个 working jsFiddle example ,它演示了如何使用该插件来显示和隐藏一系列段落。当然,这个示例也可以扩展到其他元素/场景。
请务必回复评论这是否解决了您的问题。
关于jquery - 如何使用jqPagination,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11362445/