jQuerypager.js插件动态分页功能实例分析-创新互联
本文实例讲述了jQuery pager.js 插件动态分页功能。分享给大家供大家参考,具体如下:
创新互联自2013年起,是专业互联网技术服务公司,拥有项目网站设计、成都网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元西塞山做网站,已为上家服务,为西塞山各地企业和个人服务,联系电话: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 = '
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
标题名称:jQuerypager.js插件动态分页功能实例分析-创新互联
文章分享:http://pwwzsj.com/article/cdcpjd.html