JavaScript EasyPager 分页函数_javascript技巧
程序员文章站
2024-01-30 19:35:10
...
复制代码 代码如下:
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;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)));
};
推荐阅读
-
JavaScript EasyPager 分页函数_javascript技巧
-
JQuery 表格操作(交替显示、拖动表格行、选择行等)_javascript技巧
-
兼容ie ff div 层 打开+关闭+ 拖动+遮罩+移动+动画改变高宽_javascript技巧
-
javascript获取checkbox复选框获取选中的选项_javascript技巧
-
js传参数受特殊字符影响错误的解决方法_javascript技巧
-
实现点击列表弹出列表索引的两种方式_javascript技巧
-
undefined==null引发的两者区别与联系第1/3页_javascript技巧
-
document.createElement()用法_javascript技巧
-
PHP中使用Session配合Javascript实现文件上传进度条功能_php技巧
-
JavaScript函数的特性与应用实践深入详解