views:

440

answers:

1

Hello,

I have a table structure like the one shown below:

<table id="result">
<tr>
<td id="groupx">
   <table>
   <tr>
   <td>Data</td>
  </tr>
</td>
</tr>
</table>

I want to add a TD to the last tr of table result. Trying x.appendTo($("#result tr:last")); isn't working since it's adding to the last tr of a table id "group"

Any sugestions on how I can keep using this structure of html and do this ?

Thank you for any help.

Best regards, FR

+2  A: 

While Nadia's answer was almost good, it missed one thing: browsers put all direct tr childs of a table into a tbody element, so this:

<table>
  <tr>
    <td>Lol</td>
  </tr>
</table>

gets translated internally to this:

<table>
  <tbody>
    <tr>
      <td>Lol</td>
    </tr>
  </tbody>
</table>

So all you need to do is this:

x.appendTo($("#result>tbody>tr:last"));

Let me know if it works.

DrJokepu
This was the same answer that I was about to put. It was just a matter of getting the right selector.
TehOne
Worked well, thank you !
netcrash