[jQuery] Find nearest parent with an ID

[jQuery] Find nearest parent with an ID


Hi all,
I'm wanted to traverse up the DOM to find the nearest/closest
((+great)grand)parent which has an ID.
For example
<table id="table1">
<tr>
<td id="td1">
<div>
<span>
<a class="meh" ...
...
so from
$(".meh")
I want to find "td1"
I thought I could use
$(".meh").parents("@[id]").attr("id")
but apparently not.
I may have misunderstood one or more bits of the code there...
--
View this message in context: http://www.nabble.com/Find-nearest-parent-with-an-ID-tf3356637.html#a9335652
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/