What's the proper way to use the querySelectorAll method? I'm just trying to add a click event to each div with class '.box', but it's not working. I've found that this works fine if I replace the method with 'getElementById' and just test the kitchen box.
document.querySelectorAll('.box').addEventListener('click', test);
function test() {
console.log('hi');
}
<section class="main">
<div class="box" id="kitchen"></div>
<div class="box" id="laundry"></div>
<div class="box" id="bedroom"></div>
</section>