Hi All,
Here is what i copied and mine does not work. Only the button section
here are my codes, console log says " addEventListener is not a function.
Thank you for your help in advance.
Hi All,
Here is what i copied and mine does not work. Only the button section
here are my codes, console log says " addEventListener is not a function.
Thank you for your help in advance.
You added the JS to the CSS box.
Anyway, querySelectorAll
does not return a single element, it returns a collection (NodeList). If you want to use it for a single element you have to index into it.
const btn = document.querySelectorAll("button");
btn[0].addEventListener("click", function (e) {
console.log("hello");
});
I would suggest you use querySelector
if you just want a single element.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.