Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

onMouseLeave trigger alert twice even with stopPropagation

$('.pool').on('mouseleave', function (e) {                
            var el = $(this).find('.pool-row').find('input[type=submit]');

            if (el.length)
                alert('bla bla bla');

            e.stopImmediatePropagation();
            e.stopPropagation();
            return;
        });

The alert is triggering twice on mouseleave even with stopPropagation or preventDefault and "return;".

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have made some quick modifications on your script, and it seems that it does not trigger the alert twice!

$('.pool').on('mouseleave', function (e) {
  e.stopPropagation()
  var el = $(this).find('input[type="submit"]')

  if (el.length)
      alert('bla bla bla')
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="pool">
  <p>This is a pool</p>
  
  <input type="submit">
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading