I am trying to target and eventually style a string, in this examle BLA, in an HTML page with many tested tables.
For example HTML page:
<table>
<tr>
<td><table><div><tr><td>BLA</td></tr></div></table></td>
</tr>
And the jquery script I use:
$("td:contains('BLA')");
to do it, but I see that ALL td’s are selected.. How can I just get the first td, without all the ancestors?..
And if this is possible, how can I add a class to the first ancestor when going up the DOM tree? (and just this one)
Thank you community
What you describe is the last td and not the first since they are returned in DOM hierarchy order.
demo at http://jsfiddle.net/92Xj2/
Update after clarification in comment
new demo http://jsfiddle.net/gaby/92Xj2/4/