合并行
$("#tableId").find("tr").each(function(rowIndex) {var cells = $(this).find("td");cells.each(function(cellIndex) {var cell = $(this);var prevRowCell = table.find("tr:eq(" + (rowIndex - 1) + ")").find("td:eq(" + cellIndex + ")");if (prevRowCell.html() === cell.html()) {cell.remove();prevRowCell.attr("rowspan", (prevRowCell.attr("rowspan") || 1) + 1);}});
});
合并列
<script>
$("#tableId").find("tr").each(function(rowIndex) {var cells = $(this).find("td"); cells.each(function(cellIndex) {var cell = $(this);var prevRowCell = table.find("tr:eq(" + (rowIndex - 1) + ")").find("td:eq(" + cellIndex + ")");if (prevRowCell.html() === cell.html()) {cell.remove();prevRowCell.attr("rowspan", (prevRowCell.attr("rowspan") || 1) + 1);prevRowCell.attr("colspan", (prevRowCell.attr("colspan") || 1) + 1);}});
});
👇觉得有帮助的朋友可以支持下作者哦,您的鼓励是我创作的最大动力,如有开发问题可联系作者