手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >基于jQuery实现的无刷新表格分页实例
基于jQuery实现的无刷新表格分页实例
摘要:本文实例讲述了基于jQuery实现的无刷新表格分页。分享给大家供大家参考,具体如下:效果图如下:html结构:css样式:html,body...

本文实例讲述了基于jQuery实现的无刷新表格分页。分享给大家供大家参考,具体如下:

效果图如下:

基于jQuery实现的无刷新表格分页实例1

html结构:

css样式:

html,body{margin: 0;padding:0} a:focus {outline: none;} /* 通用表格显示 */ table, th, td {font: 12px Arial,Helvetica,sans-serif,'宋体';margin: 0;padding: 0} table{border-spacing: 0;border-collapse: collapse;} .datatable {width: 100%;border-style: none;background-color: #fff;margin-bottom: 20px;text-align: left;} .datatable th, .datatable td { padding: 5px;line-height: 30px} .datatable thead th {background-color: #eee;margin: 0;text-align: left;border-top: 1px solid #cfcfcf;border-bottom: 1px solid #cfcfcf;font-weight: 500} .datatable tbody td {background-color: #fff;border-bottom: 1px solid #ddd;table-layout:fixed;word-break:break-all;font-weight: 400} .datatable tbody tr.evenrow td {background-color: #f4f4f4;} .datatable tfoot td {background-color: #fafafa;text-align: right;border-bottom: 1px solid #cfcfcf;} /*表格分页列表*/ .datatable td.paging a {border: 1px solid #eee; color: #444; margin: 4px; padding: 2px 7px; text-decoration: none; text-align:center;} /*表格分页当前页*/ .datatable td.paging a.current {background: #eee; border: 1px solid #CFCFCF; color: #444; font-weight: bold;} .datatable td.paging a.current{border: 0;cursor: auto;background:none}

javascript封装代码:

/** * 抽象化表格 */ function abstractTable(){ // ---------内容属性 this.id = null; // 每个表格都有唯一的一个id this.tableobj = null; //表格对象 this.rowNum = 0; //行数 this.colNum = 0; //列数 this.header = []; //表头数据 this.content = []; //body数据 // ----------提供外部使用获得表格内部数据 this.currentClickRowID = 0; //当前点击的行数据 // --- 通过表头来获得这张表的列数 this.getColNum = function(){ this.colNum = this.header.length; return this.colNum; } // ----------- 表格自我构建行为 this.clearTable = function(){}; this.showHeader = function(){}; this.showContent = function(begin,end){}; this.showFoot = function(){}; // --------- 分页功能属性 this.allDataNum = 0; // 总数据条数 this.displayNum = 10; // 每页显示条数 this.maxPageNum = 0; // 最大页码值 this.currentPageNum =1;// 当前页码值 //tfoot分页组 this.groupDataNum = 10; //每组显示10页 this.groupNum = 1; //当前组 // -------- 分页功能行为 this.paginationFromBeginToEnd = function(begin,end){} this.first = function(){}//首页 st = function(){}//最后一页 this.prev = function(){}//上一页 this.next = function(){}//下一页 this.goto = function(){} //跳到某页 // ----------- 表格初始化 this.init = function(begin,end){} } /* 表格对象模板 */ function tableTemplet(table_id){ abstractTable.call(this); this.id = table_id; } /** * 表格对象 * @param options */ function table(options){ if(!options){return;} if(!$.isPlainObject(options)){return;} tableTemplet.call(this,options.tableId); //得到表格对象 this.tableobj = $("#"+this.id); //清空表格内容 this.clearTable = function(){ this.tableobj.html(" "); } // 实现分页行为 this.paginationFromBeginToEnd= function(x,y){ this.maxPageNum = Math.ceil(this.allDataNum/this.displayNum); var arrPage = []; for(var i= x;i=2){ var oA = $(""); oA.attr("href","#"+(this.currentPageNum - 1)); oA.html("上一页"); $td.append(oA); } //普通显示格式 if(this.maxPageNum tempThis.currentPageNum){//下一组 if(tempThis.currentPageNum%tempThis.groupDataNum==0){ tempThis.groupNum += 1; var maxGroupNum = Math.ceil(tempThis.maxPageNum/tempThis.groupDataNum); if(tempThis.groupNum>=maxGroupNum){ tempThis.groupNum = maxGroupNum; } } } if(nowNum

【基于jQuery实现的无刷新表格分页实例】相关文章:

jQuery实现div随意拖动的实例代码(通用代码)

jQuery实现表格行上下移动和置顶效果

基于JavaScript实现动态添加删除表格的行

jQuery的Scrollify插件实现滑动到页面下一节点

javascript实现淡蓝色的鼠标拖动选择框实例

JQuery实现带排序功能的权限选择实例

jQuery实现弹出窗口中切换登录与注册表单

Javascript实现的SHA-256加密算法完整实例

jQuery实现给页面换肤的方法

Javascript实现div的toggle效果实例分析

精品推荐
分类导航