Given $('#test')
and the following DOM, how can I select the corresponding ted-collapse
?
<div id='test' class='ted-panel'>
<div class='ted-collapse'></div>
<div class='ted-panel'>
<div class='ted-collapse'></div>
<div class='ted-collapse'></div>
<div class='ted-collapse'></div>
</div>
</div>
Notes:
- The corresponding
.ted-collapse
is the element that's a child of the current.ted-panel
and not a child of any nested.ted-panel
.ted-collapse
is not guaranteed to be an immediate child of.ted-panel
Essentially, I want to (1) filter out any children .ted-panel
s, then (2) .find('.ted-collapse)
.
Here's a one-line solution based on one of the comments:
$('#test').not($('#test').find('.ted-collapse'))