简单的jQuery分页 [英] Simple jQuery Pagination
问题描述
我有一个大约50分贝的页面。我想把这些div组织成六个组,以便客户端不会得到信息过载。我已经为我的问题创建了一个简单的示例/简化测试用例。正如你所看到的,有很多div,我想要的,当页面加载时,只有前六个是可见的,但当你点击第2页或下一个,接下来的六个是显示等。您所在的页码类别也应设置为 class =current
。
I have a page with about 50 divs on it. I would like to organise these divs into groups of six, so that the client doesn't get 'information overload'. I have created a simple example/reduced test case of my problem. As you can see, there a lots of divs, and I want it so that when the page loads, only the first six are visible, but when you click on page 2 or next, the next six are revealed et cetera. The class of the page number you are on should also be set to have class="current"
.
远已经试过使用jQuery,但我已经得到相当卡住!
So far I have tried using jQuery, but I have been getting quite stuck! Any help would be much appreciated!
推荐答案
当请求页面时,隐藏所有内容div,然后迭代它们,应该出现在page:
When a page is requested, hide all content divs, then iterate through them and show those that should appear on the "page":
showPage = function(page) {
$(".content").hide();
$(".content").each(function(n) {
if (n >= pageSize * (page - 1) && n < pageSize * page)
$(this).show();
});
}
http://jsfiddle.net/jfm9y/184/
这篇关于简单的jQuery分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!