I have established my buttons:
<div class="calculator">
<div class="display">
<p class="numberContent"></p>
</div>
<div class="operations">
<button class= 'btn add'>+</button>
<button class= 'btn subtract'>-</button>
<button class= 'btn multiply'>x</button>
<button class= 'btn divide'>÷</button>
<button class= 'btn clear'>CLEAR</button>
</div>
and onwards...
In Javascript I would like to be able to add event listeners to all the buttons so I can write the code for the functionality.
I attempted this test but it throws an error: Uncaught TypeError: btn.addEventListener is not a function
let btn= document.querySelectorAll('.btn')
btn.addEventListener('click',()=>{
alert('clicked')
})
Can someone tell me why I cant add an event listener to all of the members of the class selector. Thanks