Whoops :)  that should be:

#test > li > a

That will only select the direct a tags of the LI. Previously you where
selecting all A tags of the LI. Even the A tags within the other child
elements of the LI.

--
Brandon Aaron

On 8/29/07, Brandon Aaron <[EMAIL PROTECTED]> wrote:
>
> Actually it works this way in the CSS Spec also and your test file proves
> it. Just use this selector instead of your other selector:
>
> #test > li a
>
> --
> Brandon Aaron
>
> On 8/29/07, Jeroen Coumans <[EMAIL PROTECTED]> wrote:
> >
> >
> > Thanks for the explanation, that makes sense. But this is not how the
> > CSS spec has it defined. You can see that in my test file where the
> > CSS rule is only applied to the top list items.
> >
> > The question is; is the jQuery behaviour a bug or a feature? And if
> > it's a feature, it should be documented.
> >
> > Jeroen
> >
> > On Aug 29, 2:01 pm, "Brandon Aaron" <[EMAIL PROTECTED]> wrote:
> > > Because you are binding the click event to the a tag, not the li. So
> > what
> > > your saying is get all the a tags within each li (which is all the a
> > tags in
> > > your ul). You just need one more child selector in there between the
> > li and
> > > a to make sure you only select the immediate a tags of the li only ...
> >
> > > instead of all the a tags within the li.
> > >
> > > $('#test > li > a').click(...);
> > >
> > > --
> > > Brandon Aaron
> > >
> > > On 8/29/07, Jeroen Coumans < [EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > > > Hi,
> > >
> > > > See <http://lab.jeroencoumans.nl/jquery/child-selector.html >
> > > > It's my understanding that child selectors only select direct
> > children
> > > > of an element. Thus, $('#test > li') should only select direct
> > > > descendent <li> elements of #test, not nested <li>'s. This is
> > > > confirmed with a simple CSS rule. So how come, when I attach a click
> > > > event to a direct child, it seems to attach itself to all
> > > > descendents?
> > >
> > > > Regards, Jeroen
> >
> >
>

Reply via email to