How to fix the error Uncaught TypeError: select.addEventListener is not a function?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
Here is the script
var select = document.querySelectorAll(".price-item"); select.addEventListener("click", function () { alert("Hello"); });

In the console that says Uncaught TypeError: select.addEventListener is not a function?
What to do?
by | 7 views

1 Answer

0 like 0 dislike
The result of executing the document.querySelectorAll is a NodeList (https://developer.mozilla.org/en-US/docs/Web/API/N... ) – and it is not expected to addEventListener
by

Related questions

110,608 questions
257,186 answers
0 comments
35,406 users