Javascript 分页 完美封装
来源:互联网 发布:淘宝指数排行榜 编辑:程序博客网 时间:2024/05/26 08:41
首先上效果图:
以下为封装好的 方法:
function Paging(pageNum,pageSize,totalCount,skipCount,fuctionName,currentStyleName,currentUseLink,preText,nextText,firstText,lastText){ var returnValue = ""; var begin = 1; var end = 1; var totalpage = Math.floor(totalCount / pageSize); if(totalCount % pageSize >0){ totalpage ++; } if(preText == null){ firstText = "prev"; } if(nextText == null){ nextText = "next"; } begin = pageNum - skipCount; end = pageNum + skipCount; if(begin <= 0){ end = end - begin +1; begin = 1; } if(end > totalpage){ end = totalpage; } for(count = begin;count <= end;count ++){ if(currentUseLink){ if(count == pageNum){ returnValue += "<a class=\""+currentStyleName+"\" href=\"javascript:void(0);\" onclick=\""+fuctionName+"("+count.toString()+");\">"+count.toString()+"</a> "; } else{ returnValue += "<a href=\"javascript:void(0);\" onclick=\"" + fuctionName + "(" + count.toString() + ");\">" + count.toString() + "</a> "; } } else { if (count == pageNum) { returnValue += "<span class=\""+currentStyleName+"\">"+count.toString()+"</span> "; } else{ returnValue += "<a href=\"javascript:void(0);\" onclick=\""+fuctionName+"("+count.toString()+");\">"+count.toString()+"</a> ";} } } if(pageNum - skipCount >1){ returnValue = " ... "+returnValue; } if(pageNum + skipCount < totalpage){ returnValue = returnValue + " ... "; } if(pageNum > 1){ returnValue = "<a href=\"javascript:void(0);\" onclick=\""+fuctionName+"("+(pageNum - 1).toString()+");\"> " + preText + "</a> " + returnValue; } if(pageNum < totalpage){ returnValue = returnValue + " <a href=\"javascript:void(0);\" onclick=\""+fuctionName+"("+(pageNum+1).toString()+");\">" + nextText + "</a>"; } if(firstText!= null){ if(pageNum >1){ returnValue = "<a href=\"javascript:void(0);\" onclick=\""+fuctionName+"(1);\">" + firstText + "</a> " + returnValue;} } if(lastText !=null){ if(pageNum < totalpage){ returnValue = returnValue + " " + " <a href=\"javascript:void(0);\" onclick=\""+fuctionName+"("+totalpage.toString()+");\">" + lastText + "</a>";} } return returnValue; }
- Javascript 分页 完美封装
- 数据分页模块系列 完美封装PageModel实现分页模块
- Springmvc+mybatis+maven查询分页完美封装版
- JavaScript面向对象:分页器类封装
- 数据分页模块系列 (二) 完美封装PageModel实现分页模块
- 封装分页
- 分页封装
- 分页封装
- 分页封装
- 封装分页
- 分页封装
- javascript(jquery)实现前台html简单的分页封装
- Retrofit+RxJava 完美封装
- Android 6.0完美封装
- OutputDebugString完美封装
- strut分页完美解决方案
- asp完美分页代码
- Oracle分页完美实现
- 编译安装libevent,memcache,以及php的memcached扩展
- 元组,列表,--操作符性能
- LoadRunner Sample WebTours 点击Flights出现空白解决方法
- GCC 中的编译器堆栈保护技术
- LoadRunner中文出现乱码的解决办法
- Javascript 分页 完美封装
- UVA 11426 - GCD - Extreme (II)
- Source Insight 批量注释 多行注释宏
- win7下LoadRunner监控windows资源图报错
- Android平台下与服务器数据库通信的方法
- Qt中foreach的用法
- Maven常用命令
- 判断鼠标是否在接收键盘事件的控件上
- LR检查点小结