I have html like this
<button class="pop-btn">
Pop
</button>
I was able to style it with css but I can't select it in my Javascript:
const Population_div_Button=document.querySelector(".pop-btn");
Population_div_Button.addEventListener("click", function(){
Open_Populationdiv();
});
where Open_Populationdiv()
is a function I wrote. Everything seems to be in place but I still get an error message on console, and the script doesn't work:
Uncaught TypeError: Population_div_Button is null http://127.0.0.1:5500/app.js:6