I'm coding along with responsive nav tutorial as it something that always gives me headaches and yet again I've hit a snag. The error I'm getting in the console states "Cannot read property 'addEventListener' of null" and it gives the line numbers. So I can see it is not registering the click event but I cannot figure out why.
Here's the js:
const navSlide = () => {
const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
burger.addEventListener('click', () => {
nav.classList.toggle('nav-active');
});
}
navSlide();
Worth noting that I'm using an html includes bit of js to insert the nav html into each page.
Everything else appears to be working i.e. CSS classes are correct when i make them visible in testing. All the nav-active class should do is add a transform: translateX(0%) to bring in the list.
Let me know if you need the HTML / CSS. Worth noting that I'm using a HTML include to include the navigation on each page but again that all works fine it's just this event listener for the click on the burger icon.