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

207
Vistas
How to propagate event from element with higher z-index to elements under excluding click event?

I have a component which has markers in it. Marker is a styled div with icon. Markers have click, mouseenter and mouseleave events. When mouse enters tooltip appears. On top of markers I can place other element to cover them. That element has higher z-index. I still want to be able to hover over (mouseenter, mouseleave) over lower z-index elements (markers) while preventing click event on them when they are covered. Is there any solution to pass only few or exclude only some event from propagation on higher z-index element?

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

0

<!DOCTYPE html>
<style>
    #elmHigherZindexID {
        width: 100px;
        height: 100px;
        position: absolute;
        background-color: chartreuse;
        z-index: 1000;
    }
    #elmLowerZindexID {
        width: 100px;
        height: 100px;
        position: absolute;
        background-color: cornflowerblue
    }
</style>
<body>
    <div id="elmHigherZindexID">HIGH</div>
    <div id="elmLowerZindexID">LOW</div>
</body>
<script>
    let highElmRef = document.getElementById('elmHigherZindexID');
    let lowElmRef = document.getElementById('elmLowerZindexID');
    highElmRef.addEventListener('click', highEventHandler);
    highElmRef.addEventListener('mouseenter', highOtherEventHandler);
    lowElmRef.addEventListener('mouseenter', lowEventHandler);
    function highEventHandler(event) {
        event.stopPropagation();
        console.log('high', event);
    }
    function highOtherEventHandler(event) {
        event.stopPropagation();
        console.log('high', event);
        const cusEvent = new MouseEvent('mouseenter', {
            view: window,
            bubbles: true,
            cancelable: true
        });
        lowElmRef.dispatchEvent(cusEvent);
    }
    function lowEventHandler(event) {
        event.stopPropagation();
        console.log('low', event);
    }
</script>
</html>

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