onClick event triggered twice - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

onClick event triggered twice

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from w  ww.  j a  v  a2  s . c  om
$( "#test1" ).on( "click", function(ev) {
    ev.stopPropagation();
});
$('#test1').trigger('click');
    });

      </script> 
 </head> 
 <body> 
  <span onclick="console.log('Boem')"> <button id="test1">test</button> </span>  
 </body>
</html>

Related Tutorials