James_Inger James_Inger - 2 years ago 61
Javascript Question

Jquery - Merge cells in multiple columns that are the same

I am trying to merge cells in 8 columns that have the same text content.
I can see that in the following - merging <td> rows in one column of html table, but this only works on 1 column at a time, when told to loop through columns, it does not work

Any ideas on how to do this for all columns in a table ?

Answer Source

You can achieve that by looping the data in "tr" level and eliminate the repeated entries, add the "rowspan".

The below snippet will helpful to you,

$('#tblNewAttendees tr').each(function() {
//initate the rowcount here
    $.each(this.cells, function(){
        //use after function to append the cell
          $(this).find('td').eq(0).after('<td rowspan=rowcount class="table-rowspan">==>fooo <== </td>');//instead of eq(0) use the number position you want to append

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download