Skip to content

24 ways to impress your friends

Vote down?

Scott Kosman

Good question, Darren. Logically you’d think that’s exactly how it works, but it’s actually the opposite. Sizzle (the CSS selector engine built into jQuery) parses selectors from right to left so in your case, it’ll search out all paragraphs, then determine which ones are inside div#content, and so forth.

I knocked together a quick jsperf using your example and comparing it to a couple of different options using .find(), and .find() is significantly faster.