function fenye_yxxgtjbb(divId_bao,table_bao,show_per_page_bao){ var divId_baostring="#"+divId_bao+""; divId_bao = $("#"+divId_bao+""),tableId_bao = $("#"+table_bao+""); //总条数 var number_of_items_bao = tableId_bao.find("tr").length; //共几页 var number_of_pages_bao = Math.ceil(number_of_items_bao/show_per_page_bao); //倒数第二页 var index_of_pages_bao = number_of_pages_bao-1; var current_link_bao = 0; //点击第一页 以及上一页 var navigation_html_bao = '<a class="previous_link_bao" href="javascript:go_to_page_g4test(0,\''+table_bao+'\',\''+show_per_page_bao+'\');go_first_g4test(\''+divId_baostring+'\');"><div class="first_page_bao"> </div></a><a class="previous_link_bao" href="javascript:previous_g4test(\''+divId_baostring+'\',\''+table_bao+'\','+show_per_page_bao+');"><div> </div></a>'; //Page navigation_html_bao += '<span class="page_span_bao page_span">页数</span>'; //输入框 navigation_html_bao += '<input type="text" style="width:40px;" class="num_box_bao num_box" longdesc="' + current_link_bao +'" value="'+(current_link_bao + 1)+'">'; //共多少页 navigation_html_bao += '<span class="page_span_bao page_span">至 ' + number_of_pages_bao +'</span>'; //点击下一页以及最后一页 navigation_html_bao += '<a class="next_link_bao" href="javascript:void(0)"><div> </div></a><a class="next_link_bao" href="javascript:go_to_page_g4test(' + index_of_pages_bao +',\''+table_bao+'\',\''+show_per_page_bao+'\');go_last_g4test(\''+divId_baostring+'\',\''+number_of_pages_bao+'\');"><div class="last_page_bao"> </div></a>'; //上一页方法 previous_g4test = function(divId_baostringNew,tableId_baoNew,show_per_page_baoNew){ current_link_bao=$(divId_baostringNew+" "+".num_box_bao").val(); last_page_bao = current_link_bao-2; if(last_page_bao>=0){ go_to_page_g4test(last_page_bao,tableId_baoNew,show_per_page_baoNew); current_link_bao = current_link_bao-1; $(divId_baostringNew+" "+".num_box_bao").val(parseInt($(divId_baostringNew+" "+".num_box_bao").val())-1); } }, //下一页方法 next_g4test =function(divId_baostringNew,table_baoNew,number_of_pages_baoNew,show_per_page_baoNew){ current_link_bao=$(divId_baostringNew+" "+".num_box_bao").val(); last_page_bao = current_link_bao; if(last_page_bao<number_of_pages_baoNew){ go_to_page_g4test(last_page_bao,table_baoNew,show_per_page_baoNew); current_link_bao = current_link_bao+1; $(divId_baostringNew+" "+".num_box_bao").val(parseInt($(divId_baostringNew+" "+".num_box_bao").val())+1); } }, //跳转的方法 go_to_page_g4test = function(page_num_bao,tableId_baoNew,show_per_page_baoNew){ debugger; var tableId_baoNew2 = $("#"+tableId_baoNew+""); start_from_bao = page_num_bao * show_per_page_baoNew; end_on_bao = start_from_bao + show_per_page_baoNew; $(tableId_baoNew2).find("tr").css('display', 'none').slice(start_from_bao, end_on_bao).css({ "display": "table-row", "width":"100%;" }); current_link_bao = page_num_bao; }, //去第一页样式方法 go_first_g4test = function(divId_baostringNew){ $(divId_baostringNew+" "+".num_box_bao").val(1); }, //去最后一页样式方法 go_last_g4test = function(divId_baostringNew,number_of_pages_baoNew){ $(divId_baostringNew+" "+".num_box_bao").val(number_of_pages_baoNew); }; //往页面上添加样式 $(divId_bao).html(navigation_html_bao); //第一步先让table全部隐藏 $(tableId_bao).find("tr").css({'display':'none'}); //只展示固定几条 $(tableId_bao).find("tr").slice(0, show_per_page_bao).css({ "display": "table-row", "width":"100%;"}); //增加分页图片样式 $(divId_baostring+" "+".previous_link_bao div").css({ "width":"16px","height":"16px", "background":"url("+path+"/ecspresources/images/pagination_icons.png) no-repeat", "display":"inline-block", "background-position":"-16px 3px" }); $(divId_baostring+" "+".next_link_bao div").css({ "width":"16px","height":"16px", "background":"url("+path+"/ecspresources/images/pagination_icons.png) no-repeat", "display":"inline-block", "background-position":"-16px 3px" }); $(divId_baostring+" "+".next_link_bao div").css({"background-position":"-32px 3px"}); $(divId_baostring+" "+".first_page_bao").css({"background-position":"0 3px"}); $(divId_baostring+" "+".last_page_bao").css({"background-position":"-48px 3px"}); //为下一页添加点击事件 $(divId_baostring+" "+".next_link_bao").click(function(){next_g4test(divId_baostring,table_bao,number_of_pages_bao,show_per_page_bao);}); //为输入框添加事件 $(document).ready(function(){ $(divId_baostring+" "+".num_box_bao").on({ "keydown":function(e){ var key_bao = e.which; var will_num_bao = $(this).val()-1; var max_page_bao = number_of_pages_bao-1; // alert(max_page_bao) if(key_bao == 13) { e.preventDefault(); if(will_num_bao>max_page_bao){ go_to_page_g4test(max_page_bao,table_bao,show_per_page_bao); $(this).val(max_page_bao+1); } else{go_to_page_g4test(will_num_bao,table_bao,show_per_page_bao)}; } }, "click":function(){ $(this).css({"border":"1px solid #8bade4"}); }, "blur":function(){ $(this).css({"border":"1px solid #cccccc"}); } }) }) } fenye_yxxgtjbb('Page_Fen_kgzx_khqgl','manage-content-tbody',num);