how to select ".classA .classB", but not ".classA .classA .classB"
I'm trying to implement (class-based and nestable) collapsible content with jQuery.
Starting from a specific "div.wrapper" to which I have stored a reference in $wrapper, I need to select all descendants of the type "div.collapsible", but exclude those which are also descendants of lower-down "div.wrapper" elements (that is: "div.wrapper" elements which are themselves descendants of the original "div.wrapper" pointed to by $wrapper).
I've tried the following, neither of which works:
- $wrapper.find('.collapsible:not(.wrapper .collapsible)')
- $wrapper.find('.collapsible').not('.wrapper .collapsible', this)
What can I do?
PS: In case it has any implications, the whole thing happens inside an onclick event of a trigger element, at the beginning of which I determine the $wrapper variable like this:
- var $wrapper = $(this).closest('.wrapper');