Adding a table row in jQuery
The approach you suggest is not guaranteed to give you the result you’re looking for – what if you had a tbody for example: <table id=”myTable”> <tbody> <tr>…</tr> <tr>…</tr> </tbody> </table> You would end up with the following: <table id=”myTable”> <tbody> <tr>…</tr> <tr>…</tr> </tbody> <tr>…</tr> </table> I would therefore recommend this approach instead: $(‘#myTable tr:last’).after(‘<tr>…</tr><tr>…</tr>’); … Read more