I am trying to select the highest level of tds in a nested table structure like this (inside the first level tds there are more tables with more tds that shouldn't be selected
<table>
<tr>
<td> <!-- this is what I want to select -->
<table /> <!-- more td's inside that I don't want to select -->
</td>
</tr>
<tr>
<td> <!-- this is what I want to select -->
<table /> <!-- more td's inside that I don't want to select -->
</td>
</tr>
</table>
To select the desired tds would be easy: table > tr > td. However there might be tables with tbody tags:
<table>
<tbody>
<tr>
<td> <!-- this is what I want to select -->
<table /> <!-- more td's inside that I don't want to select -->
</td>
</tr>
<tr>
<td> <!-- this is what I want to select -->
<table /> <!-- more td's inside that I don't want to select -->
</td>
</tr>
</tbody>
</table>
That itself would be easy as well: table > tbody > tr > td.
How can I find an easy expression that doesn't rely on the > child selector and works universally?
Something like table tr > td (which obviously wouldn't work since it selects tds inside the nested table. Thanks!
table > tbody > tr > tdwill work universally and would also probably be the fastest solution. Why are you against it?tbodyand will add it themselves (with some exceptions because of doctype). Also I know this sounds dull but if you only have two posibilities wouldn't a selector like$('table > tbody > tr > td', 'table > tr > td');do the trick? Without that it will require alot of parent proofing to get the righttd