同一个html自动跳转分页,一个页面有多个分页,相互影响

怎么让分页不相互影响呢?

$.each($('.results_comment'), function(index, value) {

var show_per_page = 1; //每页显示几条数据

var number_of_items = $('.results_comment').eq(index).children().size(); //获取总长度长度

var number_of_pages = Math.ceil(number_of_items / show_per_page);

$('#current_page').eq(index).val(0);

$('#show_per_page').eq(index).val(show_per_page); //5

var navigation_html = '上一页';

var current_link = 0; //变量

while (number_of_pages > current_link) {

navigation_html += '' + (current_link + 1) + '';

current_link++;

}

navigation_html += '下一页';

$('.page_navigation').eq(index).html(navigation_html);

$('.page_navigation .page_link:first').eq(index).addClass('active_page');

$('.results_comment').eq(index).children().css('display', 'none');

$('.results_comment').eq(index).children().slice(0, show_per_page).css('display', 'block');

// 分页结束

});

/ 分页方法

function previous() {

new_page = parseInt($('#current_page').val()) - 1;

if ($('.active_page').prev('.page_link').length == true) {

go_to_page(new_page);

}

}

function next() {

new_page = parseInt($('#current_page').val()) + 1;

if ($('.active_page').next('.page_link').length == true) {

go_to_page(new_page);

}

}

function go_to_page(page_num) {

var show_per_page = parseInt($('#show_per_page').val());

start_from = page_num * show_per_page;

end_on = start_from + show_per_page;

$('.results_comment').children().css('display', 'none').slice(start_from, end_on).css('display', 'block');

$('.page_link[longdesc=' + page_num + ']').addClass('active_page').siblings('.active_page').removeClass('active_page');

$('#current_page').val(page_num);

}

// 分页方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值