Following your logic, an L4 element will never be a direct child of an L1, so that would always return 0. Also you don't need two objects to do what you were trying at first, you can do $('some > thing', '#inhere')
Let me see if I understand you. Given the following mark-up: <body> <div class="L1"> <p> <span class="L3"> <a class="L4" /> </span> </p> </div> <div class="L1 thisOne"> <p> <span class="L3 other"> <a class="L4" /> </span> </p> </div> </body> You want to find only the <a> (4) elements that are children of <div> (1) AND children of <span>(3). Right. L4 is not a direct children of L1 so you need another approach. $('span.other a').filter(function(){ return !!$ (this).parents('div').length }) which equates to $('L3.other L4').filter(function(){ return !!$ (this).parents('L1').length }) or, if what you want is the opposite, to find <a>'s in <span> that are also a child of <div> $('span a').filter(function(){ return !!$ (this).parents('div.thisOne').length }) which equates to $('L3 > L4').filter(function(){ return !!$ (this).parents('L1').length }) // returns true if the element is a child of L1 There are many ways of simplifying that based on your element classes or attributes, but that's all I could come up with without seeing your HTML. cheers, - ricardo On Oct 22, 6:16 pm, Dan Finch <[EMAIL PROTECTED]> wrote: > You're right, I do that all the time :). I'm getting my side effects > mixed up. What I can't actually do is match against ancestors of the > context. For example, $( ".L1>.L4", $( ".L3" ) ), where the n > represents the level of DOM depth. > > On Oct 22, 2:38 pm, MorningZ <[EMAIL PROTECTED]> wrote: > > > Have you tried those? > > > There's no reason why > > > $( "p>a", $( "div" ) ); > > > wouldn't find all <a> that are direct descendants of <p> tags inside > > <div> tags > > > On Oct 22, 2:43 pm, Dan Finch <[EMAIL PROTECTED]> wrote: > > > > If there's a way, what would it take to be able to use complex > > > selectors (those with " ", "~", ">", etc.) with filtering functions. > > > For example, > > > > $( "div" ).find( "p>a" ); > > > $( "p>a", $( "div" ) ); > > > > Thanks- Hide quoted text - > > > - Show quoted text -