check which element was clicked with event target - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

check which element was clicked with event target

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(){// ww  w .jav  a  2  s.  c o m
$('*').on('click', function(e) {
    if(!$(e.target).is('input')){
        console.log('clicked');
    }
});
    });

      </script> 
 </head> 
 <body> 
  <input name="foo" type="text">  
 </body>
</html>

Related Tutorials