This question already has an answer here:
I am new to JavaScript, and can't get this problem solved
Error : btn.addEventListener is not a function
It works when I use query selector, but not when I getElementByClassName
HTML
<input type="text" class="amount">
<select>
<option class="option" value="1">Good</option>
<option class="option" value="2">Ok</option>
<option class="option" value="3">Bad</option>
</select>
<button class="btn"> Calculate </button>
JavaScript
const amount = document.getElementsByClassName('amount');
const btn = document.getElementsByClassName('btn');
btn.addEventListener('click', a());
function a() {
alert('100');
}
The alert fires off on the load of the window!