Pass event object to onclick event handler - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Pass event object to onclick event handler

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from w w  w  .  ja v a2s . co  m*/
window.testing = function(event){
  console.log('testing');
  console.log(event);
  console.log(this)//will the element which called the handler
}
    }

      </script> 
   </head> 
   <body> 
      <img src="http://www.java2s.com/style/download.png" onclick="testing(event)">
      click here  
   </body>
</html>

Related Tutorials