jQuery.fn.rowspan = function (colIdx) { return this.each(function () { var that; $('tr', this).each(function (row) { $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) { if (that != null && $(this).html() == $(that).html()) { rowspan = $(that).attr("rowSpan"); if (rowspan == undefined) { $(that).attr("rowSpan", 1); rowspan = $(that).attr("rowSpan"); } rowspan = Number(rowspan) + 1; $(that).attr("rowSpan", rowspan); $(this).hide(); } else { that = this; } }); }); });}
调用: $("#tableID").rowspan(0);
转载于:https://www.cnblogs.com/lichaoasd/archive/2012/01/14/2322505.html
相关资源:jQuery实现合并表格单元格中相同行操作示例