我有一个类似
的表格此表的第一列中有一个复选框。当我单击复选框时,表格将如下所示。
以下代码可将行跨度添加到表列中,但内容不会更改。
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;
}
});