Try  $("> div > div:first-child", grid)

On Sat, Mar 21, 2009 at 7:18 PM, Obinna <[email protected]> wrote:

> If I have a grid composed of row and cell div element as follows:
>
> <div class="grid">
>    <div class="row">
>        <div class="cell"/>
>        <div class="cell"/>
>        <div class="cell"/>
>    </div>
>    <div class="row">
>        <div class="cell"/>
>        <div class="cell"/>
>        <div class="cell"/>
>    </div>
>     <div class="row">
>        <div class="cell"/>
>        <div class="cell"/>
>        <div class="cell"/>
>    </div>
> </div>
>
> Assuming I have a 'grid' variable pointing to the top grid div, and  I want
> to return all the cells in the first 'column'. I would expect something like
> the following to work:
>
> $("> div > div:eq(0)", grid).
>
> Actually, this doesn't work. it returns only the very first (top-left)
> cell. To get what I want I need to do something like:
>
> $("> div:eq(0)",$("> div", grid))
>
> I suppose that operator precedence is applying the eq(0) in the first
> statement to the entire selection AFTER both children operators, but this is
> counter-intuitive as the :eq(0) implies that it is applied specifically to
> the second '>div' selector
>
> - Eric
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to