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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -