How to insert an item via Jquery so that it stays BEFORE and OUT of another specific item (I accept edits to improve the way you ask).
The following example inserts before, but within the add-mesa-de-luz-button
item.
$("#add-mesa-de-luz-button").click(function () {
$("#add-mesa-de-luz-button").prepend(
"<tr><td>Item adicionado</td></tr>"
);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><table><tr><td>Item1</td></tr><tr><td>Item2</td></tr><trid="add-mesa-de-luz-button">
<td>Botão de adicionar</td>
</tr>
</table>
The result of the HTML looks like this:
<table>
<tr>
<td>Item 1</td>
</tr>
<tr>
<td>Item 2</td>
</tr>
<tr id="add-mesa-de-luz-button">
<tr><td>Item adicionado</td></tr>
<td>Botão de adicionar</td>
</tr>
</table>
But I would like it to be inserted before and outside the add-mesa-de-luz-button
item, so that it looks like this:
<table>
<tr>
<td>Item 1</td>
</tr>
<tr>
<td>Item 2</td>
</tr>
<tr><td>Item adicionado</td></tr>
<tr id="add-mesa-de-luz-button">
<td>Botão de adicionar</td>
</tr>
</table>