Ah yes, of course. I'm glad you figured it out! I think part of the problem with our solutions was that we didn't see your actual markup.

For future reference:

$('E:nth-child(n)') will select an E element that is the nth child of its parent element. $('E').children().get(n) will select an element that is the (n+1)th child of the E element.

You should also be able to use .eq(n) if you want to keep the chain going (returns the jQuery object rather than the DOM element):

        $('E').children().eq(n)

Or you could do this:

        $('E').children(':eq(n)')

Cheers,

--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Mar 26, 2007, at 8:28 AM, MARIO MOURA wrote:

Thanks Karl

I tried but didnt work (I made a lot of variations)


but this is working fine:
$("#imagefields").append( $(".group-image").children().get(3) );

Thanks for help

Regards

Mario

2007/3/24, Karl Swedberg <[EMAIL PROTECTED]>:
$("#imagefields").append( $(".group-image":nth-child(2)) );

Hi Mario, I know you were referring to the other Karl below, but if you don't mind, I'll jump in with an answer (I posted another response to your original post, because my email program didn't have it threaded with the the replies and I thought nobody had answered yet).

You're almost there. You just need to put the quotation marks around the pseudo-class as well. So, this should work:
  $("#imagefields").append( $(".group-image:nth-child(2)") );



--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Mar 24, 2007, at 6:03 AM, MARIO MOURA wrote:

Evan

Thanks a lot your solution works for me.

My real example is:
$("#imagefields").append( $(".group-image").children().get(2) );

But I am curious about what Karl said I tried a lot of things but I believe I have a error syntax.

$("#imagefields").append( $(".group-image":2-child(n)) );
or I tried too
$("#imagefields").append( $(".group-image":nth-child(2)) );

What is wrong?
Regards

macm

2007/3/24, Evan <[EMAIL PROTECTED] >:
You could also use get(), though it's probably slower

$('div').children().get(1);

On Mar 24, 3:04 pm, "Karl Rudd" <[EMAIL PROTECTED]> wrote:
> Have read of this page:
>
>    http://docs.jquery.com/Selectors#CSS_Selectors
>
> Especially E:nth-child(n)
>
> Karl Rudd
>
> On 3/24/07, MARIO MOURA <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi
>
> > I am newbie
>
> > How can I get a second children element?
>
> > In firebug I have
>
> > ---DIV
> > ------FIELD
> > ------FIELD
> > ------FIELD
> > ------FIELD
> > ------FIELD
>
> > My problem is all children have same name. How can I get second and after
> > the third...
>
> > Regards
>
> > --
> > macm
> > _______________________________________________
> > jQuery mailing list
> > [EMAIL PROTECTED]
> >http://jquery.com/discuss/
>
> _______________________________________________
> jQuery mailing list
> [EMAIL PROTECTED]://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



--
Mário Alberto Chaves Moura
[EMAIL PROTECTED]
31-9157-6000
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/




--
Mário Alberto Chaves Moura
[EMAIL PROTECTED]
31-9157-6000
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to