Best way to add tr element mid-way through a list of table rows - jQuery
- by soulBit
Hi all, first post on the site!
I'm looking for some help inserting tr elements mid-way through a simple table like the one below:
<table id="content">
<tr class="item">
<td><p>header content</p></td>
</tr>
<tr class="item">
<td><p>footer content</p></td>
</tr>
</table>
I am adding elements using jQuery with the following code:
$('<tr class="item" />').insertAfter('#content tr:first');
However after adding an element using this command, I would like to add some more (but after the last added item, not at the top of the list)
Im sure there are simple ways of doing this (by assigning an id to the footer element, and using .insertBefore('#footer') for example) but it would be interesting to know some different techniques that could be used. Thanks in advance! :)