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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c# - Setting Server Bindings of IIS 6.0 Programmatically -

Python + DNS : Cannot get RRSIG records: No Answer -