(function(dfsj_jq){ dfsj_jq.fn.pagination = function(option){ var self = this, cached = {}; option = dfsj_jq.extend({ target:dfsj_jq('ul li'), perpage:10, pagetotal:10, r_num:10 },option); option.total = Math.ceil(option.pagetotal/option.perpage); //添加分页元素相应的事件 var initEvent = function(ele){ ele.find('a').bind('click',function(){ var self = dfsj_jq(this); ele.children().remove(); ele.html(makePagnation(self.attr('page')) || ''); initEvent(ele); dfsj_jq(window).scrollTop(670); }); ele.find('.custompage2').bind('keydown',function(event){ if(event.keyCode == 13){ var self = dfsj_jq(this), val = self.val(), total = self.attr('maxPage'); if(/[\d]+/.test(val)){ val = parseInt(val); if(val>0 && val <= total){ ele.children().remove(); ele.html(makePagnation(val) || ''); initEvent(ele); } } } }) } //生成分页HTML var makePagnation = function(cur){ cur = parseInt(cur); if(cur <1 || cur > option.total)return ''; //控制显示的行数 option.target.each(function(key){ var max = cur * option.perpage - 1, min = (cur-1) * option.perpage self = dfsj_jq(this); if(key>=min && key <=max){ self.show(); var img = self.find('.nex_fnl_img img'), img_src = img.attr('src'); !img_src && img.attr('src',img.attr('src_data')); }else{ self.hide(); } }); //在分页缓存中查找 if(cached[cur])return cached[cur]; var i =2, tmpl = ['