I do not have advanced jquery knowledge and I need to go through all the rows of a html table and hide the entire Line if the column from 5 JUS) is empty and refresh the sequence numbering of the first Id column, eg:
I want to hide the entire row if 5 and 6 (and if there is 7,8, n ...) column is empty:
Ineedyoutolooklikethis:
Ineededtohidethecolumnsandusedthecodebelowsuggestedandacceptedby Felipe Duarte in this post How to traverse all columns of a table with jquery and hide if empty
var i = 1;
$('table.grid tr td').each(function (el) {
if ($(this).text() == '') {
$('table.grid td:nth-child(' + i + '), th:nth-child(' + i + ')').hide();
}
i++;
})
This is the current structure of my table:
<table class="grid">
<thead>
<tr class="head">
<th>ID</th>
<th>Empresa</th>
<th>PAR</th>
<th>Data</th>
<th>JUS</th>
<th>ST</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">1 </td>
</tr>
</tfoot>
<tbody>
<tr>
<td>A1</td>
<td>A2</td>
<td>A3</td>
<td>A4</td>
<td>A5</td>
<td>A6</td>
</tr>
<tr>
<td>B1</td>
<td>B2</td>
<td>B3</td>
<td>B4</td>
<td></td>
<td>B6</td>
</tr>
<tr>
<td>C1</td>
<td>C2</td>
<td>C3</td>
<td>C4</td>
<td>C5</td>
<td>C6</td>
</tr>
</tbody>
</table>