Can jQuery perform a compound select against the top level only? (a.k.a. "How to avoid chaining chil

Posted by harpo on Stack Overflow See other posts from Stack Overflow or by harpo
Published on 2010-05-12T17:54:40Z Indexed on 2010/05/12 18:14 UTC
Read the original article Hit count: 203

Filed under:
|
|

Basically, is there a way to write

a.children('.outer').children('.inner')

without the intermediate selector? I can't write

$('.outer > .inner', a)

because I don't want to do full-depth search against a — I know that the .outer elements are immediate children of a.

It's partly a matter of "elegance", but partly because I'm trying to avoid "throwaway" element sets. Yes, jQuery may in effect do the same thing, but it has a better chance of optimizing (at least in theory), when it knows the full query's intent.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors