Here is the HTML code I am working with:
<button class="pop-btn">
Pop
</button>
While I was able to style this button using CSS, I encountered a problem when trying to select it in Javascript:
const Population_div_Button=document.querySelector(".pop-btn");
Population_div_Button.addEventListener("click", function(){
Open_Populationdiv();
});
The function Open_Populationdiv()
is defined by me. Although all seems to be set up correctly, I keep receiving an error message in the console and the script fails to execute:
Uncaught TypeError: Population_div_Button is null http://127.0.0.1:5500/app.js:6