Search code examples
jqueryhtml-tablechildren

jQuery selector children


I need to select tbody and insert some tr inside this section:

<div id="retour">
<table>
    <thead>
    </thead>
    <tbody>
    </tbody>
</table>
</div>

I have tried the following code, but it didn't work:

var table = $('#retour > table > tbody').children();
table.append('<tr>');
table.append( '<td>' + 'MyInfos' + '</td>' );
table.append('</tr>');

Solution

  • i think you need

    var table = $('#retour > table > tbody');
    table.append('<tr><td>' + 'MyInfos' + '</td></tr>');