Question

I am missing something pretty simple here, I need to add a td in the 2nd table. I cannot get it and I know its something simple. I shortened it up for intense and purposes:

<div id="content_area">
 <table>
    <table></table>
 </table>
 <table>
    <tr>
      <td> // I want to add another TD before this
        <table></table>
        <table></table>
      </td>  
    </tr>
 </table>
</div>


 $('#content_area').find('table:eq(1)').find('td').before('<td>Data</td>');
Was it helpful?

Solution

 $('#content_area').find('>table:eq(1)').find('td').before('<td>Data</td>');

If you don't use the ">" the second table will be the one into the first table.

OTHER TIPS

 $('#content_area table:nth-child(2) tr').prepend('<td>Data</td>');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top