Event.PreventDefault to stop event bubble - Javascript DOM Event

Javascript examples for DOM Event:preventDefault

Description

Event.PreventDefault to stop event bubble

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(){/*w  w  w  . j av  a 2 s.  co m*/
$("input[type='checkbox']").on('mousedown',function(evt) {
      evt.preventDefault();
      console.log(this.checked);
 });
    });

      </script> 
 </head> 
 <body> 
  <input type="checkbox"> 
  <br> 
  <input type="checkbox" checked>  
 </body>
</html>

Related Tutorials