I would like to know how to obtain the number of divs, in this case from the div_principal class, that are not included in the div of the div_global class? In this case it should return value.
<div class="div_global">
<div class="div_principal"></div>
<div class="div_principal"></div>
<div class="div_principal"></div>
</div>
<div class="div_principal"></div>
<div class="div_principal"></div>
You can use
.not()
to remove the<div>
ones inside.<div>
within<div class="div_global">
<div class="div_principal">
you have and add their<div>
child elements to them.The variable
dife
has what you need.A simpler version. In this case we look for the
.div_principal
direct descendants ofbody
with the selection operator>
:you can use this code
you can try it in this fiddle