How to CSS select each first div without class following after div with certain class? Example:
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div></div>
<div></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div></div>
<div></div>
<div></div>
<div class="someclass"></div>
<div class="someclass"></div>
Is it possible to select it without JS/JQuery?
you can try using following CSS
.someclass + div:not(.someclass, .someclass) {
}
Use can pass multiple values in not selector if you have different classes in this structure
try https://jsfiddle.net/jr9wsr49/
CSS
.someclass + div:not(.someclass) {
background:green
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With