코드 복사 코드는 다음과 같습니다. 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>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>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>ChangeCenterBar( pageindex 1) ; <br>} <br>var pageClick=function(e) <br>{ <br>var targetPage=parseInt(e.target.innerText) <br>pageindex=targePage; ' targetPage "페이지"); <br>ChangeCenterBar(targetPage); <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('페이지 인덱스는 다음과 같습니다. ' 크기 '페이지'에 도달함); <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'); 바인딩 해제('click',preClick); <BR>$('.next').unbind('click',nextClick) <BR>$('.last').unbind('click',lastClick); 🎜 >$('.SEID').bind('change',SeClick) <BR>$('.first').bind('click',firstClick) <BR>$('.pre'); 바인딩('클릭',preClick); <BR>$('.next').bind('click',nextClick) <BR>$('.last').bind('click',lastClick); 🎜 >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); > $("#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>// 경고(9) <BR>var startIndex=(currentSec-1)*centersize 1 <BR>for(startIndex;startIndex<=currentSec*centersize;startIndex ) <BR>{ <BR>//alert( startIndex) <BR>//alert('max' 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; 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<=((currentSec-1)*centersize size�ntersize);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>{ <br>alert('分页出错'); <br>} <br>} <br>} <br>} <br>PageReinit(); <br>} <br>PageInit(); <br>