Working on a dynamically built table I can clone a row and manipulate it incrementing name{keys] removing attributes and classes as needed and in most cases place this clone at the end of the table using
clone().appendTo($('table tr:last'));
OR
clone().appendTo("#TBody");
OR
clone().appendTo("#TBody tr:last");
But the table content is dynamic in that some cases the cell would have rowspan="number" on some of the cells followed by a new <tr> which has cells for the other columns. For example.
<tbody id="TBody">
<tr class="d-none">
<td rowspan="2"></td>
<td rowspan="2"></td>
<td rowspan="2"></td>
<td></td>
<td></td>
<td></td>
</tr>
<!-- New row is being placed here -->
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<!-- New row should go here -->
</tbody>
and so when adding a row using any method above the row is NOT being added after the last <tr> row but instead after the last full row, which breaks the table. So tr:last is NOT pointing to the last <tr>. It should go before </tbody>. Any ideas?
… and looking at these lines of code that I wasn’t even looking at the section where I am manipulating newClone AND THEN ADD IT TO page with insertAfter(); daaa!
After just defining newClone
var newClone = secondlast.clone();
… and changing the insertAfter() line to this everything works great.
newClone.insertAfter("#TBody tr:last-of-type");
I guess I need a break after I clean up this mess… Thanks for your help!