Get window.event.target - Javascript DOM Event

Javascript examples for DOM Event:target

Description

Get window.event.target

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <input value="click" type="button" onclick="grabId(event)"> 
      <script>
    function grabId(event) {/*  ww w  . j ava2  s  .c  o m*/
      var targ;
      if (!e) var e = event;
      if (e.target) targ = e.target;
      else if (e.srcElement) targ = e.srcElement;
      if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode;
    }
  
      </script>  
   </body>
</html>

Related Tutorials