I have 3 input
fields for numbers, and I'd like to fire in the console log, every time I input a number in any of the 3 input
fields. I've added a for loop for the addEventListener
, but there's still the error showing that this addEventListener
part is not a function. I'd like to ask what am I missing for the code to be realized?
Thank you so much!
HTML:
<input type="number" id="no1">
<input type="number" id="no2">
<input type="number" id="no3">
JS:
const val = document.getElementsByTagName("input");
for (i = 0; i < val.length; i++) {
val[i].addEventListener("input", () => {
console.log(val[i].value);
});
}