I'm going astray trying to get the closest previous element with a class βslideβ that DOES NOT contain a subdivision of a class using jQuery
HTML example:
<section id="p1" class="slide"></section> <section id="p2" class="slide"></section> <section id="p3" class="slide"></section> <section id="p31" class="slide subsection"></section> <section id="p32" class="slide subsection"></section> <section id="p4" class="slide"></section>
I tried: (where $ subsection is the above item)
var $slide = $subsection.prev('.slide').not('.subsection'); var $slide = $subsection.prev('.slide:not(".subsection")'); var $slide = $subsection.prev('.slide').not("[class='subsection']"); var $slide = $subsection.prev('.slide:not([class="subsection"])');
Now I found out that prev () selects only one previous item and then stops, but does prevUntil not work either?
var $slide = $subsection.prevUntil('.slide').not('.subsection');
I also tried:
var $slide = $subsection.prevAll('.slide').not('.subsection');
but this gives me the very first element of the slide with id p1.
If anyone has any clues, I will be grateful ... Can someone stop me to escape? 8- |
source share