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

154
Vistas
event.stopPropagation(); prevents own function as well

I have a button inside a whole clickable div and I tried to add event.stopPropagation(); to the end of the button function, but the function itself is also being ignored.

What's wrong about the following code?

var mobileCaptionToggle = document.getElementsByClassName("mobile-caption-toggle");
var b;
for (b = 0; b < mobileCaptionToggle.length; b++) {
  mobileCaptionToggle[b].addEventListener("click", function(event) {
    var mobileCaptionOverlay = this.parentNode.children[0].children[0].children[0].children[0].children[1];
    mobileCaptionOverlay.classList.toggle("visible");
    mobileCaptionOverlay.addEventListener("click", function() {
        mobileCaptionOverlay.classList.toggle("visible");
      }); 

      event.stopPropagation();
  });
}

about 4 years ago · Santiago Gelvez
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