Given this sample markup (assuming a random number of elements between .outer
and .inner
:
-
If the .inner
are always direct children of .outer
s - children() is probably your best bet (jasongetsdown's answer)
If you need something that looks even deeper, you could do something like this:
var $outer = $('.outer').first(); // grab the first .outer
$outer.find('.inner').filter(function() {
// only if the closest parent .outer is the same as the .outer we are looking in
return $(this).closest('.outer').get(0) == $outer.get(0);
}).css('border','1px solid #000');
jsfiddle demo