jquery append a tr after calling

Posted by marharépa on Stack Overflow See other posts from Stack Overflow or by marharépa
Published on 2010-04-24T10:28:46Z Indexed on 2010/04/24 10:33 UTC
Read the original article Hit count: 254

Filed under:
|
|
|
|

Hello!

I've got a table.

<table id="servers" ...>
...
{section name=i loop=$ownsites}
<tr id="site_id_{$ownsites[i].id}">
...
<td>{$ownsites[i].phone}</td>
<td class="icon"><a id="{$ownsites[i].id}" onClick="return makedeleterow(this.getAttribute('id'));" ...></a></td>
</tr>       
{/section}
<tbody>
</table>

And this java script.

<script type="text/javascript">
function makedeleterow(id)
    {
        $('#delete').remove();
        $('#servers').append($(document.createElement("tr")).attr({id: "delete"}));
        $('#delete').append($(document.createElement("td")).attr({colspan: "9", id: "deleter"}));
        $('#deleter').text('Biztosan törölni szeretnéd ezt a weblapod?');
        $('#deleter').append($(document.createElement("input")).attr({type: "submit", id: id, onClick: "return truedeleterow(this.getAttribute('id'))"}));
        $('#deleter').append($(document.createElement("input")).attr({type: "hidden", name: "website_del", value: id}));
    }
</script>

It's workin fine, it makes a TR after the table's last tr and put the info to it, and the delete also works fine.

But i'd like to make this AFTER the tr which calling the script. How can i do this?

I've tried it with closest() but not work :(

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about table