首页 > 解决方案 > 使用jquery单击复选框内的列时添加行跨度

问题描述

我有一张像

在此处输入图像描述

此表在第一列中有一个复选框。当我单击复选框时,表格将如下所示。

选中复选框后的图像

以下代码将行跨度添加到表列但内容没有改变。

 var previous = null, cellToExtend = null, rowspan = 1;
             $j(".positions-table").find("td:nth-child(3)").each(function(index, e){

                var jthis = $j(this), content = jthis.text();
                if (previous != null && $j.inArray(index, self.firstColumnBrakes) === -1) {
                    // hide the row instead of remove(), so the DOM index won't "move" inside loop.
                    jthis.addClass('hidden');
                    cellToExtend.attr("rowspan", (rowspan = rowspan+1));

                }else{
                    // store row breaks only for the first column:
                    if(i === 1) self.firstColumnBrakes.push(index);
                    cellToExtend = jthis;
                    previous = content;
                }
             });

标签: jquery

解决方案


推荐阅读