// http://blog.csdn.net/tongyiyi/article/details/51159470 // $("table").rowspan(0); // 如果要合并多列中的行,则多次调用.rowspan()方法 (function ($) { 'use strict' $.fn.extend({ // 表格合并单元格,colIdx要合并的列序号,从0开始 rowspan: function (colIdx) { return this.each(function () { var that $('tr', this).each(function () { $('td:eq(' + colIdx + ')', this).filter(':visible').each(function () { if (that !== null && $(this).html() === $(that).html()) { var rowspan = $(that).attr('rowSpan') if (typeof (rowspan) === 'undefined') { $(that).attr('rowSpan', 1) rowspan = $(that).attr('rowSpan') } rowspan = Number(rowspan) + 1 $(that).attr('rowSpan', rowspan) $(this).addClass('no-word').hide() } else { that = this } }) }) }) } }) })(jQuery)