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

219
Vistas
Propagation MouseEvent And Target Style Query

I have 2 containers, one on top of the other, being controlled by zIndex whether event is mouseover/mouseout;

There is an issue with event bubbling whereby the child element fires off the parent event. I could change the event to mouseleave from mouseout which resolves the issue but how would I go about then changing the zIndex of the target element?

giphyContainer.addEventListener('mouseover', (e) => {

    let backPanel = e.target.parentElement.querySelector('.giphyImg__Back');
    let frontPanel = e.target.parentElement.querySelector('.giphyImg__Front');
    let target = e.target;
    
    if (target.className === "giphyImg__Front") {
        frontPanel.style.zIndex = "-3";
        backPanel.style.zIndex = "3";
    }
});

giphyContainer.addEventListener('mouseleave', (e) => {

    // Previously worked with event of mouseout
    // let backPanel = e.target.parentElement.querySelector('.giphyImg__Back');
    // let frontPanel = e.target.parentElement.querySelector('.giphyImg__Front');

    // console.log(backPanel);
    // e.target - event that troggered the event
    // e.currentTarget - the event listener element

    console.log(e);
    let backPanel2 = e.target.firstChild.lastElementChild;
    let frontPanel2 = e.target.firstChild.firstElementChild;
    console.log(backPanel2);
    console.log(frontPanel2);

    if (backPanel2.className === "giphyImg__Back") {
        frontPanel2.style.zIndex = 3;
        backPanel2.style.zIndex = -3;
    }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can stop the event from bubbling on to the parent by using event.stopPropagation() on your child elements.

child.addEventListener('mouseout',(event) => {
  event.stopPropagation();
})
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