jquery合并表头单元格
来源:互联网 发布:深圳软件开发待遇 编辑:程序博客网 时间:2024/05/29 10:09
Ps:本例使用jquery-1.11.3.js
本例的功能为合并<th>,检测字符为下划线
前>>
后>>
<table> <tr><th>cdhe</th><th>cd_he</th><th>cd_s12_1</th><th>cd_s12_2</th><th>ad_he</th><th>cdhe</th><th>cd_he</th><th>cd_s12_1</th><th>cd_s12_2</th><th>ad_he</th></tr> <tr><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td><td>dcde</td></tr> </table>
$(function () { $.fn.muliTh = function () { var arrs = [], a1 = [], maxLength = 0; var that = $(this); that.find('th').each(function () { a1 = $(this).html().replace(/^\s|\s$/g, "").replace(/\s+/g, "").split('_'); maxLength < a1.length ? maxLength = a1.length : 1; arrs.push(a1); }) that.find('th').hide(); var createTh = ''; for (i = 0; i < maxLength; i++) { createTh += "<tr class='jg_func jg_muliTh'>"; for (a = 0; b = that.find('th').length, a < b; a++) { if (arrs[a][i]) { createTh += "<th colspan='1' par='" + (function (list, para) { return para - 1 < 0 ? 'par' : list[para - 1]; })(arrs[a], i) + "' rowspan='" + (function (x, y, z) { var rs = 1; !y[z + 1] ? rs = x + 1 - y.length : rs = 1; return rs; })(maxLength, arrs[a], i) + "'>" + arrs[a][i] + "</th>"; //(maxLength + 1 - arrs[a].length) } } createTh += "</tr>"; } that.prepend(createTh); $('.jg_muliTh').each(function () { $(this).find('th').each(function () { var a2 = $(this); if (a2.html() === a2.prev().html() && a2.attr('par') === a2.prev().attr('par')) { a2.prev().attr('colspan', 1 + +a2.prev().attr('colspan')); a2.remove(); } }) }) console.log(arrs); } }) window.onload = function () { $('table').muliTh(); }
0 0
- jquery合并表头单元格
- jQuery EasyUI 合并表头单元格
- GridView合并表头单元格
- GridView合并单元格表头!
- Swing 表头合并单元格
- 合并 GridView 的表头单元格
- zk column表头合并单元格
- DataGridView合并表头实现 、二维表头的实现、单元格合并
- 用jQuery合并表格中左侧表头同列相同文本的相邻单元格
- 用jQuery合并表格中左侧表头同列相同文本的相邻单元格
- jquery 修改合并单元格
- jQuery合并单元格方法
- jquery 动态合并单元格
- JQuery合并相邻单元格
- jquery 合并单元格
- jquery合并单元格
- jquery table合并单元格
- jquery合并单元格
- 触发器
- 网络架构重组--目前三大运营商存在的“僵硬”问题解决方法
- 数据库事务的ACID
- python并发的痛——多线程
- LIBSVM与LIBLINEAR(一)
- jquery合并表头单元格
- USACO | Greedy Gift Givers
- Ubuntu下交换Esc和Caps Lock按键
- 线性图形混合
- 关于导入lxml,出现image not found的解决方法。
- js获取当前日期时间“yyyy-MM-dd HH:MM:SS”
- Java中Date,Calendar,Timestamp的区别以及相互转换与使用
- php配置文件修改
- Linux yum操作时出现Error: xz compression not available