复制代码 代码如下: jquery分页控件 <br>var pageindex=1; <br>var totelsize=60; <br>var centersize=5; <br>var pagesize=0; <br>var totelSec=0; <br>var outStr=""; <br>var se="<select class=\"SEID\">" <br>+"<option>5</option>" <br>+"<option selected=\"selected\" >10</option>" <br>+"<option>15</option>" <br>+"</select>"; <br>var firstdiv="<div class=\"first\">首页</div>"; <br>var prediv="<div class=\"pre\">上一页</div>"; <br>var centerdiv="<div class=\"centerclass\"></div>"; <br>var nextdiv="<div class=\"next\">下一页</div>"; <br>var lastdiv="<div class=\"last\">最后一页</div>"; <br>$('.pager').empty(); <br>$('.pager').append(se) <br>$('.pager').append(firstdiv) <br>$('.pager').append(prediv) <br>$('.pager').append(centerdiv) <br>$('.pager').append(nextdiv) <br>$('.pager').append(lastdiv) <br>function PageInit() <br>{ <br>var size=0; <br>var barObj=this; <br>var PageReinit=function() <br>{ <br>pagesize=$(".SEID option:selected")[0].innerText; <br>size=parseInt(totelsize/pagesize) <br>var lastSize=totelsize%pagesize;//最后一页显示记录 <br>if(lastSize>0) <br>{ <br>size=size 1; <br>} <br>totelSec=parseInt(size/centersize); <br>var leftSize=size�ntersize;//最后一个区段的显示记录 <br>if(leftSize>0) <br>{ <br>totelSec =totelSec 1; <br>} <br>PageBarinit(); <br>} <br>var reSetPage=function() <br>{ <br>pageindex=1; <br>pagesize=0; <br>totelSec=0; <br>outStr=""; <br>} <br>// alert('总页数:' size) <br>// alert('总区段:' totelSec) <br>// alert('每页记录数:' pagesize); <br>var SeClick=function(e) <br>{ <br>var Selectindex=e.target[e.target.selectedIndex].innerText; <br>pagesize=parseInt(Selectindex); <br>alert('每页显示:' Selectindex); <br>reSetPage(); <br>PageReinit(); <br>} <br>var firstClick=function(e) <br>{ <br>alert('点击到首页'); <br>if(pageindex!=1) <br>{ <br>pageindex=1; <br>alert('到了第1页'); <br>} <br>} <br>var preClick=function(e) <br>{ <br>alert('点击到上一页'); <br>if(pageindex!=1) <br>{ <br>pageindex =pageindex-1; <br>alert('到了第' pageindex '页'); <br>} <br>ChangeCenterBar(pageindex 1); <br>} <br>var pageClick=function(e) <br>{ <br>var targePage=parseInt(e.target.innerText); <br>pageindex=targePage; <br>alert('点击了第' targePage "页"); <br>ChangeCenterBar(targePage); <br>} <br>var nextClick=function(e) <br>{ <br>alert('点击了下一页'); <br>if(pageindex<size) <BR>{ <BR>pageindex =pageindex 1; <BR>if(pageindex==size) <BR>{ <BR>alert('到了最后一页'); <BR>} <BR>else{ <BR>alert('到了第' pageindex '页'); <BR>} <BR>} <BR>ChangeCenterBar(pageindex-1); <BR>} <BR>var lastClick=function(e) <BR>{ <BR>alert('点击了最后一页'); <BR>if(pageindex<size) <BR>{ <BR>pageindex=size; <BR>alert('到了第' size '页'); <BR>} <BR>} <BR>var ChangeCenterBar=function(CurrentIndex) <BR>{ <BR>var currentSec=parseInt(CurrentIndex/centersize); <BR>if( CurrentIndex�ntersize==1) <BR>{ <BR>if(currentSec<totelSec) <BR>{ PageBarinit();} <BR>} <BR>if(CurrentIndex�ntersize==0) <BR>{ <BR>var currentSec=parseInt(CurrentIndex/centersize); <BR>if(currentSec<totelSec) <BR>{ PageBarinit();} <BR>} <BR>} <BR>var PageBarinit=function() <BR>{ <BR>$('.SEID').unbind('change',SeClick); <BR>$('.first').unbind('click',firstClick); <BR>$('.pre').unbind('click',preClick); <BR>$('.next').unbind('click',nextClick); <BR>$('.last').unbind('click',lastClick); <BR>$('.SEID').bind('change',SeClick); <BR>$('.first').bind('click',firstClick); <BR>$('.pre').bind('click',preClick); <BR>$('.next').bind('click',nextClick); <BR>$('.last').bind('click',lastClick); <BR>if(size<=centersize) <BR>{ <BR>$('.centerclass').empty(); <BR>for(var i=1;i<=size;i ) <BR>{ <BR>var cdiv="<span id='Page_" String(i) "'>" i "</span>"; <br>$('.centerclass').append(cdiv); <br>$("#Page_" i).bind('click',pageClick); <br>} <br>}else if(size>centersize) <br>{ <br>$('.centerclass').empty(); <br>if( pageindex�ntersize==0) <br>{ <br>var currentSec=parseInt(pageindex/centersize);//当前区段 <br>if(currentSec<totelSec) <BR>{ <BR>// alert(9) <BR>var startIndex=(currentSec-1)*centersize 1; <BR>for(startIndex;startIndex<=currentSec*centersize;startIndex ) <BR>{ <BR>//alert(startIndex) <BR>//alert('最大' currentSec*centersize); <BR>var cdiv="<span id='Page_" String(startIndex) "'>" startIndex "</span>"; <br>$('.centerclass').append(cdiv); <br>$("#Page_" startIndex).bind('click',pageClick); <br>} <br>} <br>else if(currentSec==totelSec) <br>{ <br>var startIndex=(currentSec-1)*centersize 1; <br>for(startIndex;startIndex<=currentSec*centersize;startIndex ) <BR>{ <BR>var cdiv="<span id='Page_" String(startIndex) "'>" startIndex "</span>"; <br>$('.centerclass').append(cdiv); <br>$("#Page_" startIndex).bind('click',pageClick); <br>} <br>}else{ <br>alert('分页出错'); <br>} <br>}else if(pageindex�ntersize>0) <br>{ <br>var currentSec=parseInt(pageindex/centersize) 1;//当前区段 <br>if(currentSec<totelSec) <BR>{ <BR>var startIndex=(currentSec-1)*centersize 1; <BR>for(startIndex;startIndex<=((currentSec-1)*centersize centersize);startIndex ) <BR>{ <BR>var cdiv="<span id='Page_" String(startIndex) "'>" startIndex "</span>"; <br>$('.centerclass').append(cdiv); <br>$("#Page_" startIndex).bind('click',pageClick); <br>} <br>}<br>else if(currentSec==totelSec){ <br>var startIndex=(currentSec-1)*centersize 1; <br>for(startIndex;startIndex{ <br>var cdiv="<span id='Page_" String(startIndex) "' >” startIndex "</span>"; <br>$('.centerclass').append(cdiv); <br>$("#Page_" startIndex).bind('click',pageClick); <br>} <br>}else <br>{ <br>alert('分页错误'); <br>} <br>} <br>} <br>} <br>PageReinit(); <br>} <br>PageInit(); <br></脚本> <br> </div>