".nav li a"  is very different to ".nav li > a"

in the second statement (".nav li > a") only the anchors that are direct descendant of "li" elements will be chosen in the first statement (".nav li a" ) every anchor will be picked, direct or indirect descendant

----- Original Message ----- From: "brian" <bally.z...@gmail.com>
To: <jquery-en@googlegroups.com>
Sent: Tuesday, June 30, 2009 11:45 AM
Subject: [jQuery] Re: ul.nav a VS. .nav li > a



I can't speak for Sizzle but, if you'll only ever have one "nav"
element on a page, you're better off using an ID than a class.

On Tue, Jun 30, 2009 at 8:03 AM, north<ollo...@web.de> wrote:

Hi,

yesterday I read an article about jQuery performance. In one part the
author talks about selectors and uses

.nav li a

as an example. He states that before jQuery 1.3., the selector

ul.nav a

would have been the best way to get all links in the list. In jQuery
1.3., due to the inclusion of Sizzle,

.nav li > a

"should" be the best way. He doesn't mention any speed tests though,
and only briefly explains that the reason for this is Sizzle's way of
walking through selectors from right to left.

Can anyone confirm this "theory"?

Thanks!

Reply via email to