I am making a university project in Django and when I load the JS for the responsive burger menu of the nav, it does not load properly I suppose. So the problem is that when I inspect it in chrome and check the loaded files, from the JS file which is:
const navSlide = () => {
const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links')
const navLinks = document.querySelectorAll('.nav-links li');
burger.addEventListener('click', () => {
// toggle nav
nav.classList.toggle('nav-active');
// animate links
navLinks.forEach((link, index) => {
if(link.style.animation) {
link.style.animation = ''
} else {
link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.3}s`;
}
});
// burger animation
burger.classList.toggle('toggle');
});
}
navSlide();
On the event listener, it says "cannot add a property 'addEventListener' of null". Any suggestions on how to fix that?