Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
Why is toggle active not working in the below code?

I am confused by the steps on how to post code on stackoverflow. Please look at codepen for entire code:

Codepen

        const hamburger = document.querySelector(".hamburger");
        const navMenu = document.querySelector(".nav-menu");

        hamburger.addEventListener("click", () => {
            hamburger.classList.toggle("active");
            navMenu.classList.toggle("active");         
        })

        document.querySelectorAll(".nav-link").forEach(n => n.addEventListener("click", () => {
            hamburger.classList.remove("active");
            navMenu.classList.remove("active");
        }))

Sorry, trying to learn by playing with html, css, and javascript from scratch. I was wondering how to build a hamburger menu from scratch. Looked up some tutorial on youtube. Copied the code. The hamburger menu is clickable and changes to a drop down navigation bar. And clicking it again, returns it back to a hamburger menu. Developer tool shows the hamburger class changes to hamburger active then back to hamburger class. But when I added the grid container code under the navbar class, the hamburger menu no longer responds to clicks. I don't know why it no longer toggle to active. Can someone please explain. Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's a tipo error:

<textarea id="descript" name="description" placeholder="detail description*" rows="1" column="8"> </textarea>

You must close the "<textarea"

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda