我需要在JS分頁在JS
調整這個分頁正如你可以從這個樣本見
pageSize = 3;
resultN = null;
showPage = function(page) {
$(".content").hide();
$(".content").each(function(n) {
if (n >= pageSize * (page - 1) && n < pageSize * page)
$(this).show();
});
}
showPage(1);
$("#pagin li a").click(function() {
$("#pagin li a").removeClass("current");
$(this).addClass("current");
showPage(parseInt($(this).text()))
});
第1頁,用戶可以看到DIV/1/2/3/
當用戶點擊第2頁的腳本顯示/ 4/5/6/
我瓦特應該改變這個腳本,所以當用戶點擊他會看到/ 2/3/4/
,當他點擊頁面3時,他會看到/ 3/4/5 /等等。
你能指出我在正確的方向嗎?
編輯 - 修訂版(感謝Kolink & dencey)
var pageSize = 3;
var showPage = function(page) {
$(".content").hide();
$(".content").each(function(n) {
if (n >= (page - 1) && n < (page - 1) + pageSize)
$(this).show();
});
}
showPage(1);
$("#pagin li a").click(function() {
$("#pagin li a").removeClass("current");
$(this).addClass("current");
showPage(parseInt($(this).text()))
});
+ 1我會打敗你,如果我不是我的iPad:P – Hubro
它的偉大工程,在這種情況下,我使用SHOWPAGE(0);從第一個元素開始。非常感謝 – GibboK