How to auto-close a responsive nav bar?

Hi guys !

I followed a tutorial to make a responsive navigation menu on my website ( my curriculum vitae )
Actually this menu can be close only by clicking on the “hamburger div” but I want this menu to automatically close when users click on the links or click out of the menu.

I suppose I need a condition to say something like " IF users clicked on a link or out ouf the menu SO toggle-of the menu "

If anyone can explain me what I have to do it would be awesome ! I don’t have the level in Js to know what to do :sweat_smile:


  • 1 Nav section containing a UL (class = “nav-links”)
    with few links like the classics “about” “contact”…

  • 1 Div (class =" burger") that contain 3 child as the 3 burger’s lines.

Here is the JavaScript :

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 Bar** 

    **//Animate Links**
    navLinks.forEach((link, index) => {
   = ''
        }else {
   = `navLinkFade 0.5s ease forwards ${index / 7 + 0.3}s`;

    **// Burger animation**


If you need more infos just ask,
thanks you !