Reputation: 101
I am trying to use after()
to place more DOM data (a <table>
) after a $('tr')
; I am noticing that the width of the new element changes the width of the tr's first td element. What can I do to prevent that?
$('#table tr').click(function(){
$(this).after(table);
$('#data').slideDown("slow");
});
Upvotes: 0
Views: 42
Reputation: 64657
As the comments stated, you can't have a table
element in that position, and you should not repeat id's. You CAN, however, have multiple tbody
elements, as well as multiple elements with the same class, which is likely the solution you are going for:
var table = '<tbody class="data" style="display:none;"><tr><td>Test</td><td>Test</td> <td>Test</td></tr></tbody>';
$('#table').on('click', 'tr', function(){
$(this).closest('tbody').after(table);
$('.data').last().slideDown("slow");
});
Upvotes: 1