Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

81
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda