dom - jQuery parent selectors -
is there jquery parent selector traverses dom until first match found?
eg:
<tr> <td> <div id="foo">hello!</div> </td> </tr>
to find row div using:
$('#foo').parent().parent();
it feels should able write like
$('#foo').firstparent('tr');
but can't find such function in docs.
you can use .closest()
this:
$('#foo').closest('tr');
if helps, there's category narrow future searches to: tree traversal
Comments
Post a Comment