纯js分页
function goPage_article(pno,psize){
var itable = jQuery("#resultsBox .market_update_list");
var num = itable.length;
var pageSize = psize;
var totalPage = 0;
psize = psize || 6;
if(pno>1){
var first_market = jQuery('#resultsBox .market_first').length;
if(first_market > 0){
jQuery('#resultsBox .market_first').hide();
}
}else if(pno == 1){
var first_market = jQuery('#resultsBox .market_first').length;
if(first_market > 0){
jQuery('#resultsBox .market_first').show();
}
}
if(num/pageSize > parseInt(num/pageSize)){
totalPage=parseInt(num/pageSize)+1;
}else{
totalPage=parseInt(num/pageSize);
}
var currentPage = parseInt(pno);
var startRow = (currentPage - 1) * pageSize+1;
var endRow = currentPage * pageSize;
endRow = (endRow > num)? num : endRow;
for(var i=1;i<(num+1);i++){
var irow = itable[i-1];
if(i>=startRow && i<=endRow){
if( i == startRow && i !== 1 ){
if(irow.childNodes[1].childNodes[1].className.indexOf('first_post') == -1){
irow.setAttribute("style" ," max-width:100%;flex:0 0 100% ")
irow.childNodes[1].childNodes[1].classList.add('first_post')
}
}
irow.style.display = "block";
}else{
irow.style.display = "none";
}
}
var tempStr ='<div class="tech_ana_pagination" id = "page_ajax_active"><div class="tech_ana_previous"><div>';
if(currentPage > 1){
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(1)+","+psize+")\"> << </a>";
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(currentPage-1)+","+psize+")\"> < </a>";
}
if(currentPage -2 > 0){
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(currentPage-2)+","+psize+")\"> "+(currentPage -2)+" </a>";
}
if(currentPage -1 > 0){
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(currentPage-1)+","+psize+")\"> "+(currentPage -1)+" </a>";
}
tempStr += "<span class='current' style=' display: inline-block;line-height:40px;'> "+currentPage+" </span>";
if(currentPage +1 <= totalPage){
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(currentPage+1)+","+psize+")\"> "+(currentPage +1)+" </a>";
}
if(currentPage +2 <= totalPage){
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(currentPage+2)+","+psize+")\"> "+(currentPage +2)+" </a>";
}
if(currentPage < totalPage){
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(currentPage+1)+","+psize+")\"> ></a>";
tempStr += "<a class='inactive' href=\"javascript:void(0)\" onClick=\"goPage_article("+(totalPage)+","+psize+")\"> >> </a>";
}
tempStr += '<div></div><div>' ;
if(jQuery('#page_ajax_active').length){
jQuery('#page_ajax_active').remove();
}
jQuery("#resultsBox").append(tempStr);
}