I have a basic HTMl table like this...
jQuery(document).ready(function() {
/* Calculate Total */
jQuery('table tr.customRow').each(function(i, row) {
console.log('Found Row');
jQuery(this).append('<tr>New Test Row</tr>');
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr class="customRow">
<td>
My Row 1
</td>
</tr>
<tr class="customRow">
<td>
My Row 2
</td>
</tr>
<tr class="customRow">
<td>
My Row 3
</td>
</tr>
</table>
I am trying to use jQuery to add a new <tr> above each found <tr> using append. The console log shows that it is finding the rows but is not adding the new one.
Where am I going wrong?