Jump to menu

Vote up?

  1. 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.

    http://jsperf.com/yet-another-jquery-selector-test