jQuery – append to table rows

If you use jQuery for everyday, it might be wonderful to learn how you can do an “append” for your tablet without your lines goes amork.

Even I have started using a very smart method which makes I can remove tr’s without my rows / fields breaks down.

Start to create your table so it looks like this

<table>
<thead>
<tr>
<th>Titel</th>
</tr></thead>
<tbody id="test">
</tbody>
</table>

Now you have made ​​your javascript to execute an append to your table’s tbody

function testAppend()
{
var contentData = '';
contentData += '<tr>';
contentData += '<td></td>';
contentData += '</tr>';
$('#test').append( contentData );
}

After you have created this JavaScript function, you now just lie it on a button with an onclick and so it seems.

Leave a Reply

Your email address will not be published. Required fields are marked *

*