On Feb 4, 2009, at 1:09 AM, Pedram wrote:
Thanks Karl , It helped me alot
Not a problem. Glad to help.
Since it's not possible in a valid DOM to have an A that is a descendant of a UL but not a descendant of an LI, the LI is superfluous. No need to do an extra getElementsByTagName there.
On second thought, I'm not sure that there would actually be an extra getElementsByTagName as of jQuery 1.3, since Sizzle (1.3's selector engine) starts on the right side of the selector and then walks up the DOM tree, checking for matches on each selector to the left in turn. It might still matter, but it probably matters less. Please don't take these musings as fact, though. I have not run any comparative benchmarks. You would have to do that to know for sure which is faster.
If someone else has benchmarks on these things, I'd be interested to see them. Also, I haven't taken a close look at Sizzle, so my understanding of it could be off. Please, anyone, feel free to correct me.
Cheers, --Karl ____________ Karl Swedberg www.englishrules.com www.learningjquery.com