How can i include all .article-full h2
and .article-full h3
from the DOM structure except the h2 and h3 contained in
.toc-excluded
I tried
const headings = document.querySelectorAll(
".article--full :not(.toc-excluded) h2, .article--full :not(.toc-excluded) h3"
);
headings.forEach(hd => hd.classList.add("red"))
.red {
color: red;
}
<div class='article--full'>
<div>many divs in between</div>
<div class='toc-excluded'>
<div>many divs in between</div>
<h2>h2</h2>
<h3>h3</h3>
</div>
<div>many divs in between</div>
<div class='manyotherdivs'><h2>h2</h2></div>
<div class='manyotherdivs'><h3>h3</h3></div>
</div>