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

128
Vistas
How to terminate the mouseleave effect value?

When you will click on the box, you will see the change in test on mouseleave. And when you will click on the button, again a change in the test. When the mouseleave on the box, after we click on button, how can we remove that event happend on the test and change it to the original position?

Here is the code:- https://jsfiddle.net/jcg8e0yL/

const test = document.getElementById('test');

['pointerdown', 'mousedown', 'touchstart'].forEach(function(item) {
        document.body.addEventListener(item, function(e) {
            if(e.target.classList.contains('ignore')) {
                
                test.innerHTML = 'HOw to terminate the up effect?';
                
            } else {
      
        }
        });
    });

['pointerup', 'mouseleave', 'touchend'].forEach(function(item) {
        document.body.addEventListener(item, function(e) {
            if(e.target.classList.contains('container')) {
                
                test.innerHTML = 'Mouseleave';
                
            } else {
      
        }
        });
    });
    
<h2 id="test" class="test">
  Previous
</h2>

<div class="container">
  <button style="cursor: pointer;" class="ignore">Click me</button>
</div>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I understood you correctly, you want revert the changes made by clicking the button when cursor leaves the red box? In that case you could simply add useCapture parameter when registering an event listener:

['pointerup', 'mouseleave', 'touchend'].forEach(function(item) {
        document.body.addEventListener(item, function(e) {
            if(e.target.classList.contains('container')) {
                
                test.innerHTML = 'Mouseleave';
                
            } else {
      
        }
        }, true); //useCapture
    });
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