<table>
<tbody>
<tr>
<td class="TargetRow">Not this one</td>
</tr>
</tbody>
<tbody> ... </tbody>
<tbody>
<tr>
<td class="TargetRow">This one</td>
</tr>
</tbody>
<tbody> ... </tbody>
<tbody>
<tr class="ContextRow"> ... </tr>
</tbody>
</table>
Given the above HTML I'm trying to find a way of getting the contents of the preceding tr of class TargetRow. I.e. for the first preceding tbody that contains a td.TargetRow return the td.TargetRow
I'm using jQuery, at present I can get hold of the tbody containing the ContextRow using:
jQuery(contextRow).parents("tbody").first()
How can I now find the previous sibling of that tbody that contains tr.ContextRow?
If there was just a way for me to say from contextRow walk up the DOM tree until you find an element matching "td.TargetRow" then that would be ideal.
Many Thanks.