Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
¿Cómo terminar el valor del efecto mouseleave?

Cuando haga clic en el cuadro, verá el cambio en la prueba en mouseleave. Y cuando haga clic en el botón, nuevamente un cambio en la prueba. Cuando el mouse deja el cuadro, después de hacer clic en el botón, ¿cómo podemos eliminar ese evento que sucedió en la prueba y cambiarlo a la posición original?

Aquí está el código: - 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 answers
Answer question

0

Si lo entendí correctamente, ¿quiere revertir los cambios realizados haciendo clic en el botón cuando el cursor sale del cuadro rojo? En ese caso, simplemente podría agregar el parámetro useCapture al registrar un detector de eventos:

 ['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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!