javascript

javascript

javascript – add a line<tr> before another line that has an ID

Question: I need to add a row at a specific position in a table using Javascript . Example: <table> <tr><td>Teste</td></tr> <!– Inserir linha aqui! –> <tr id=”id_2″> <td>Teste 2</td> </tr> </table> Answer: Using jQuery, you can use insertBefore , like this: $(“<tr><td>Outro teste</td></tr>”).insertBefore(“#id_2”); Or with pure Javascript, without jQuery: var …

javascript – add a line<tr> before another line that has an ID Read More »

Scroll to Top