[jQuery] Re: jQuery nodes traversing

2008-12-20 Thread Ricardo Tomasi
or $('h2').parents('[id]:first') sorry 'bout the flooding :) On Dec 20, 9:57 pm, Ricardo Tomasi wrote: > $('h2').parents('[id]') > > should work! > > On Dec 20, 8:17 am, "graphic...@googlemail.com" > > wrote: > > Hi, > > > Thanks for helping. I think I haven't explained properly what I > > wan

[jQuery] Re: jQuery nodes traversing

2008-12-20 Thread Ricardo Tomasi
$('h2').parents('[id]') should work! On Dec 20, 8:17 am, "graphic...@googlemail.com" wrote: > Hi, > > Thanks for helping. I think I haven't explained properly what I > wanted > > I'm looking for the first parent with an attribute 'id', which in this > example was .  However it could be any

[jQuery] Re: jQuery nodes traversing

2008-12-20 Thread graphic...@googlemail.com
Hi, Thanks for helping. I think I haven't explained properly what I wanted I'm looking for the first parent with an attribute 'id', which in this example was . However it could be anything, not necessary "main", so your code wouldn't work as you are looking specifically for "#main". I thin

[jQuery] Re: jQuery nodes traversing

2008-12-19 Thread Ricardo Tomasi
To get the #main parent you'd use $('h2').parents('#main') You can get indexes for all parents in 'inside out' order, or use the index() function to calculate them: $('h2').parents().each(function(index){ // p index == 0 // div index == 1 // #main index == 2 $(this).parent().childre