Question User Question User - 1 year ago 67
jQuery Question

how to add the table row after the given id in jquery

Fiddle

How to add the

<tr>
after the given
<tr>
ID in JQuery

Below is the JQuery code :

$('#tableclick').click(function(){
$('#tr_second').append('<tr><td>test1</td><td>test2</td><td>test3</td></tr>');
});


Expected Output

test1 test2 test3
test1 test2 test3
test1 test2 test3

Answer Source

You can use after() instead of append() DEMO

$('#tableclick').click(function() {
  $('#tr_second').after('<tr><td>test1</td><td>test2</td><td>test3</td></tr>');
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download