title: How to pass event as argument to an inline event handler in JavaScript?
body: <pre class="lang-javascript prettyprint-override"><code>// this e works
  document.getElementById("p").oncontextmenu = function(e) {
      e = e || window.event;
      var target = e.target || e.srcElement;
      console.log(target);
  };
  
  // this e is undefined
  function doSomething(e) {
      e = e || window.event;
      var target = e.target || e.srcElement;
      console.log(target);
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;p id="p" onclick="doSomething(e)"&gt;
      &lt;a href="#"&gt;foo&lt;/a&gt;
      &lt;span&gt;bar&lt;/span&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>There are some similar questions have been asked.</p>
  
  <p>But in my code, <strong>I'm trying to get child elements who's been clicked, like <code>a</code> or <code>span</code></strong>.</p>
  
  <p>So what is the correct way to pass <code>event</code> as an argument to event handler, or how to get event inside handler without passing an argument?</p>
  
  <h1>edit</h1>
  
  <p>I'm aware of <code>addEventListener</code> and <code>jQuery</code>, please provide a solution for passing event to <code>inline</code> event hander.</p>