user1768401 user1768401 - 1 year ago 101
jQuery Question

JQuery hide table columns with rowspan

I want to hide a table column, but using jQuery

on columns with rowspan attribute seems to "pass" that attribute to the previous row and mess up the table.

$('#tbl td:last-child').toggle();

Look at the simple example at:

Any ideas?

Answer Source

Thanks to the @dystroy for his input.

Based on his answer, here's the simple solution:

var lastChilds = $('#tbl td:last-child');
    var rowSpan = $(this).attr('rowspan');
    if(rowSpan !== undefined){
      lastChilds.splice(i+1, rowSpan-1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download