Blair
On 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/