I know how to select similarly named class name or ID if there are in the same direct parent, meaning if there are in the same box, proof https://codepen.io/akpobi/pen/poPddMr. But if there are more boxes and I'm trying to target all the buttons in their separate parents, it doesn't work. Help.
const btn = document.querySelector(".btn");
const box = document.querySelector(".box");
const boxInternal = document.querySelector(".box-internal").childNodes;
const popFunc = function(event) {
for (const boxInternals of boxInternal) {
if (event.target == boxInternals) {
box.classList.toggle("box-scale");
}
}
};
btn.addEventListener("click", popFunc, false)
<div class="box-wrapper">
<div class="box">
<div class="box-internal">
<button class="btn">Click</button>
</div>
</div>
<div class="box">
<div class="box-internal">
<button class="btn">Click</button>
</div>
</div>
<div class="box">
<div class="box-internal">
<button class="btn">Click</button>
</div>
</div>
</div>