Thanks leeoniya ! But ":eq(0)" can't work in my case. Work as ":first" and so return an only one element, so can't get each parent of each matched element :/.
I'll look for the closest method. But think it should be very interesting to get a "first-ancestor" as we have a "first-child". On 14 jan, 17:21, Leeoniya <[email protected]> wrote: > you should now be able to use .closest(), although i agree, the naming > should have been firstancest or something. closest sounds too much > like a sibling traversal. > > i currently constructs like .parents("li:eq(0)") all over the place, > pretty much identical to Karl's sugg. i think i'll be switching to > "closest", but be careful, closest can return itself as well if it > matches, so in a situation like this, they would return the same > results: > > <div> > <div id="foo"> > </div> > </div> > > $("#foo").parent("div"); // should return the outer div > $("#foo").parents("div:eq(0)"); // should return the outer div > $("#foo").closest("div"); // should return the inner div > > Leon > > On Jan 14, 9:57 am, Just <[email protected]> wrote: > > > No response about that ? Is it so dumby :P ? > > > On 16 déc 2008, 16:34, Just <[email protected]> wrote: > > > > Hi Ricardo ! > > > Thanks to answering :). > > > > Yea should be "first-ancestor" so. > > > > On 16 déc, 13:43, Ricardo Tomasi <[email protected]> wrote: > > > > > If you'll allow me, I believe what Just suggested should indeed be > > > > possible with CSS only, as the same can be achieved in the other > > > > direction. But the naming is confusing, there is only one possible > > > > parent so 'first-parent' would be redundant. > > > > > Wouldn't that be the case of making the :first pseudo-class match the > > > > first element for each traversal/element? It's replicating the > > > > functionality of eq(0) anyway. > > > > > Or maybe some 'reverse' selectors: > > > > $('input.toto < li:first') > > > > > On Dec 15, 3:10 pm, Karl Swedberg <[email protected]> wrote: > > > > > > You could do this: > > > > > > $('input.toto').each(function() { > > > > > $(this).parents('li:first').remove(); > > > > > > }); > > > > > > --Karl > > > > > > ____________ > > > > > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > > > > > On Dec 15, 2008, at 9:35 AM, Just wrote: > > > > > > > Hi John :), > > > > > > and thanks to answering. > > > > > > > Because, as the :first is defined, it just removed the first element > > > > > > matched by $('input.toto').parents('li:first'). > > > > > > Not first LI parent of each element (here each first LI parent of > > > > > > EACH > > > > > > input element having the class "toto"). > > > > > > > That's my problem so. > > > > > > > I thinks that's why first-child exists too. > > > > > > > On 12 déc, 18:40, "John Resig" <[email protected]> wrote: > > > > > >> Why not just do: > > > > > >> $('input.toto').parents('li:first').remove(); > > > > > > >> --John > > > > > > >> On Fri, Dec 12, 2008 at 9:54 AM, Just <[email protected]> > > > > > >> wrote: > > > > > > >>> Hi, > > > > > > >>> Example : I have list into other list, in few LI element I've got > > > > > >>> input. I want to take all input element which have the class > > > > > >>> "toto" > > > > > >>> and remove the LI which is the parent of the input (not the direct > > > > > >>> ancestor ;)). > > > > > > >>> So it will be good if I could do something like: > > > > > >>> $('input.toto').parents('li:first-parent').remove(); > > > > > > >>> What about that please ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---
