That did the trick. Thanks for the help.
But I must (regretfully) say that the documentation on this point is lacking.
It seems to me that parents() and ancestors() are the same except for the order of objects returned.
parents() = parent[0], grandparent[1]
ancestors() = grandparent[0], parent[1]
Perhaps the someone could add this simple explanation to the documentation.
I appreciate everyone's help,
Derrek
On 10/18/06, Blair McKenzie <[EMAIL PROTECTED]> wrote:
Try :first. I think parents() actually works differently from the other filters, in that the elements are in reverse order (parent is [0], grandparent is [1]).
BlairOn 10/19/06, Derrek <[EMAIL PROTECTED]> wrote:Hi John,
Say I have:
<table id="tbl_a">
<tr id="tr_x"><td></td></tr>
<tr id="tr_y"><td></td></tr>
<tr id="tr_z"><td></td></tr>
<tr id="tr_a">
<td id="td_a">
<table id="tbl_b">
<tr id="tr_b">
<td id="td_b">
<input id="myInput" type="text" />
</td>
</tr>
</table>
</td>
</tr>
</table>
If I do $('#myInput').parents('tr:last').before('<tr> ... </tr>')
Then the the new row appears between <tr id="tr_z"> and <tr id="tr_a"> and not between <table id="tbl_b"> and <tr id="tr_b"> like I would expect.
Did I screw up something?On 10/18/06, John Resig < [EMAIL PROTECTED]> wrote:> Yeah, but if I have a table embedded within a table (ugh, I know) then I
> find both the <tr>s. I tried parents('tr').get(0), but that's not right
> either.
The issue is that that the <tr>s are returned in the order in which
they're in the document. So the highest <tr> in the document is
returned first. So the best way to do this is by doing:
$(...).parents("tr:last")
Which will give you the last <tr> found (but the one closest to your
starting element).
--John
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/