Jquery add table row after the row which calling the jquery.

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 11:33 UTC
Read the original article Hit count: 332

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 function also works fine.

But i'd like to make this append AFTER the tr (with td class="icon") which calling the script. How can i do this?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about table