I'm in a situation where I need to get all the "parent" elements of a div, but I can not get all because it would not solve my problem. I wonder if I can put a limit on getting these elements. With an example it becomes clearer. Consider the structure:
<div class="all">
<div class="1">
<div class="2">
<div class="3">
<div class="4">
<!-- Conteúdo -->
</div>
</div>
</div>
</div>
</div>
In this case I would like to get all the parent elements of the div with class 4
, with the exception of the all
class div, but I also want all those above .all
. Is it possible to do this via jquery?