Is there a jQuery parent selector that traverses the DOM until the first match is found?
For instance:
<tr>
<td>
<div id="foo">hello!</div>
</td>
</tr>
to find the line from the div I'm using:
$('#foo').parent().parent();
It seems to me that I should write something like
$('#foo').firstParent('tr');
but I can not find such a function in the docs.
source
share