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

82
Vistas
Close menu when user clicks on div

How can I check if a user is clicking on a div called right-side-container and if they are remove the class of menu-opened.

    toggleMenu() {
      this.open = !this.open;
      document.getElementsByTagName("html")[0].classList.toggle("menu-opened");
      if (this.open) {
        document.addEventListener("click", this.menuClickListener);
      } else {
        document.removeEventListener("click", this.menuClickListener);
      }
    },
    menuClickListener($event) {
      console.log($event);
    },
  },
}; 


// This is what I want to remove when the user is clicking the right-side-container
document.getElementsByTagName("html")[0].classList.remove("menu-opened");
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I guess you want to open/close menu on click. So you can do this in Vue:

export default {
  data() {
    return {
      show: true
    }
  },
  methods: {
    toggle() {
      // my different actions...
      this.show = !this.show
    }
  }
}
<div v-if="show">
  My menu
</div>
<div @click="toggleMenu">
  Your button/container to show/hide menu
</div>

Here you attach your variable "show" to display or not the element you want. And you attach your "click" function to the element you want to click to show/hide your element.

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