Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda