本文實(shí)例講述了jQuery pager.js 插件動態(tài)分頁功能。分享給大家供大家參考,具體如下:
創(chuàng)新互聯(lián)自2013年起,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計、成都網(wǎng)站設(shè)計網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元西塞山做網(wǎng)站,已為上家服務(wù),為西塞山各地企業(yè)和個人服務(wù),聯(lián)系電話:18982081108pager.js 代碼
function Page(opt){ var set = $.extend({num:null,startnum:1,elem:null,callback:null},opt||{}); if(set.startnum>set.num||set.startnum<1){ set.startnum = 1; } var n = 0,htm = ''; var clickpages = { elem:set.elem, num:set.num, callback:set.callback, init:function(){ this.elem.next('div.pageJump').children('.button').unbind('click') this.JumpPages(); this.elem.children('li').click(function () { var txt = $(this).children('a').text(); var page = '', ele = null; var page1 = parseInt(clickpages.elem.children('li.active').attr('page')); if (isNaN(parseInt(txt))) { switch (txt) { case '下一頁': if (page1 == clickpages.num) { return; } if (page1 >= (clickpages.num - 2) || clickpages.num <= 6 || page1 < 3) { ele = clickpages.elem.children('li.active').next(); } else { clickpages.newPages('next', page1 + 1); ele = clickpages.elem.children('li.active'); } break; case '上一頁': if (page1 == '1') { return; } if (page1 >= (clickpages.num - 1) || page1 <= 3 || clickpages.num <= 6) { ele = clickpages.elem.children('li.active').prev(); } else { clickpages.newPages('prev', page1 - 1); ele = clickpages.elem.children('li.active'); } break; case '首頁': if (page1 == '1') { return; } if (clickpages.num > 6) { clickpages.newPages('首頁', 1); } ele = clickpages.elem.children('li[page=1]'); break; case '尾頁': if (page1 == clickpages.num) { return; } if (clickpages.num > 6) { clickpages.newPages('尾頁', clickpages.num); } ele = clickpages.elem.children('li[page=' + clickpages.num + ']'); break; case '...': return; } } else { // if ((parseInt(txt) >= (clickpages.num - 3) || parseInt(txt) <= 3) && clickpages.num > 6) { // clickpages.newPages('jump', parseInt(txt)); // } // ele = $(this); // } // page = clickpages.actPages(ele); // if (page != '' && page != page1) { // if (clickpages.callback){ // clickpages.callback(parseInt(page)); // } var i = parseInt(txt); if(isNaN(i)||(i<=0)||i>clickpages.num){ return; }else if(clickpages.num>6){ clickpages.newPages('jump',i); }else{ var ele = clickpages.elem.children('li[page='+i+']'); clickpages.actPages(ele); if (clickpages.callback){ clickpages.callback(i); } return; } if (clickpages.callback){ clickpages.callback(i); } } }); }, //active actPages:function (ele) { ele.addClass('active').siblings().removeClass('active'); return clickpages.elem.children('li.active').text(); }, JumpPages:function () { this.elem.next('div.pageJump').children('.button').click(function(){ var i = parseInt($(this).siblings('input').val()); if(isNaN(i)||(i<=0)||i>clickpages.num){ return; }else if(clickpages.num>6){ clickpages.newPages('jump',i); }else{ var ele = clickpages.elem.children('li[page='+i+']'); clickpages.actPages(ele); if (clickpages.callback){ clickpages.callback(i); } return; } if (clickpages.callback){ clickpages.callback(i); } }) }, //newpages newPages:function (type, i) { var html = "",htmlLeft="",htmlRight="",htmlC=""; var HL = '
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。