有谁可以帮助我吗?我对JS几乎一无所知...我尝试了brianpeiris编写的 this示例。它工作得很好,但是我需要在同一页面中使用两个不同的传呼机。我该怎么做?
这段代码不起作用,但这就是我走了多远。
<script type="text/javascript">
var pagination_options = {
num_edge_entries: 1,
num_display_entries: 8,
callback: pageselectCallback,
items_per_page:1
}
function pageselectCallback(page_index, jq){
var items_per_page = pagination_options.items_per_page;
var offset = page_index * items_per_page;
var new_content = $('#hiddenresult div.result').slice(offset, offset + items_per_page).clone();
$('#Searchresult').empty().append(new_content);
var items_per_page = pagination_options.items_per_page;
var offset = page_index * items_per_page;
var new_content = $('#hiddenresult2 div.result2').slice(offset, offset + items_per_page).clone();
$('#Searchresult2').empty().append(new_content);
return false;
}
function initPagination() {
var num_entries = $('#hiddenresult div.result').length;
// Create pagination element
$("#Pagination").pagination(num_entries, pagination_options);
num_entries = $('#hiddenresult2 div.result2').length;
// Create pagination element
$("#Pagination2").pagination(num_entries, pagination_options);
}
$(document).ready(function(){
initPagination();
});
最佳答案
尝试这个:
var pagination_options = {
num_edge_entries: 2,
num_display_entries: 8,
callback: pageselectCallback,
items_per_page:3
};
var pagination_options2 = {
num_edge_entries: 2,
num_display_entries: 8,
callback: pageselectCallback2,
items_per_page:3
};
function pageselectCallback(page_index, jq){
var items_per_page = pagination_options.items_per_page;
var offset = page_index * items_per_page;
var new_content = $('#hiddenresult div.result').slice(offset, offset + items_per_page).clone();
$('#Searchresult').empty().append(new_content);
return false;
}
function pageselectCallback2(page_index, jq){
var items_per_page = pagination_options2.items_per_page;
var offset = page_index * items_per_page;
var new_content = $('#hiddenresult2 div.result').slice(offset, offset + items_per_page).clone();
$('#Searchresult2').empty().append(new_content);
return false;
}
function initPagination() {
var num_entries = $('#hiddenresult div.result').length;
// Create pagination element
$("#Pagination").pagination(num_entries, pagination_options);
num_entries = $('#hiddenresult2 div.result').length;
// Create pagination element
$("#Pagination2").pagination(num_entries, pagination_options2)
}
$(document).ready(function(){
initPagination();
});
关于javascript - JavaScript分页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3616660/