首页 > web前端 > js教程 > JavaScript EasyPager 分页函数_javascript技巧

JavaScript EasyPager 分页函数_javascript技巧

WBOY
发布: 2016-05-16 18:06:09
原创
945 人浏览过
复制代码 代码如下:

var EasyPager = function(wrap,pageCount,currPage){
var d = document
,el = function(tag,inner,click,css){
tag = d.createElement(tag);
inner && (tag.innerHTML = inner);
click && (tag.onclick = click);
css && (tag.className=css);
return tag;
}
,append = function(parent,children,child){
children = [].concat(children);
for(var i=0,j=children.length;ichild = children[i];
child && parent.appendChild(child);
}
return parent;
}
,easyFn = function(n){return function(){EasyPager(wrap,pageCount,n)}}
,box = el("div"),firstPage,prevPage,lastPage,nextPage,startNum,endNum,pages= [];

currPage!=1 && (firstPage = el("span","currPage!=pageCount && (lastPage = el("span",">>",easyFn(pageCount)),nextPage = el("span",">",easyFn(currPage+1)));
(pageCount=pageCount-5)&&(endNum=pageCount,startNum=pageCount-10+1));
for(var i=startNum;i
append((wrap.innerHTML="",wrap),append(box,[firstPage,prevPage].concat(pages).concat(nextPage,lastPage)));
};
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板