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