Search code examples
jqueryfindadditionprepend

jQuery find 2nd Table add TD


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>');

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.