I can't make my click addEventListener work

Joined
Dec 30, 2022
Messages
2
Reaction score
0
hi, i'm trying to make a responsive navigation bar following a tutorial i found on youtube, i've gone through everything, checked multiple times my syntax etc... but i still can't find what the problem is here, i'm trying to make the nav bar appear when i click on it, but i just doesn't work



here's the app.js code:

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 + 1.3}s`;
}
});
//Burger Animation
burger.classList.toggle('toggle');
});

}
navSlide();






thanks if anyone could help me to make it work!!
 
Joined
Jul 3, 2022
Messages
93
Reaction score
23
It would be good if you provide the whole page source together with the markup, but not only the script. Just to let the others try your code instead of creating new markup based on your js
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top