So I asked a very similar question yesterday about nested lists thinking that I would be able to use the answer both for creating nested lists and nested tables. But when I try to modify the jQuery to created nested tables it goes a little haywire. Either it doesn't nest or it nests an entire table with the child <tr>'s under the parent <tr> instead of just the child <tr>'s. Sample tables:
<table>
<tbody>
<tr id="10"><td>Parent 1</td></tr>
<tr id="14"><td>Parent 2</td></tr>
</tbody>
</table>
<table>
<tbody>
<tr class="10"><td>Child A</td></tr>
<tr class="10"><td>Child B</td></tr>
<tr Class="14"><td>Child X</td></tr>
</tbody>
</table>
(This jQuery is based on code that vzwick very graciously helped me with) The jQuery looks like this:
$('tbody.csTR_children tr').each(function() {
probable_parent = $('tbody.csTR_parent tr#' + $(this).attr('class'));
if (probable_parent.length) {
if (!probable_parent.find('tbody').length) probable_parent.append('<tbody/>');
$(this).detach().appendTo(probable_parent.find('tbody'));
}
});
This is the closest I get and it nests an entire table under each parent row (in IE it nests the first parent and child properly but the rest it doesn't), as I said above. Any suggestions?