Use caller.arguments[] to get event trigger - Javascript DOM

Javascript examples for DOM:Event

Description

Use caller.arguments[] to get event trigger

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <title>  mrmoje</title> 
      <style>

div{cursor:pointer}
div:hover{text-decoration:underline}


      </style> 
   </head> 
   <body translate="no"> 
      <div onclick="myHandler()" id="my element's id">
         Click Here//from   w w  w .j a v a 2s. co m
      </div> 
      <script>
      function myHandler(){
          console.log(myHandler.caller.arguments[0].target.id)
      }
    
      </script>  
   </body>
</html>

Related Tutorials