For instance, I have li. Inside I have paragraphs, spans…
<ul>
  <li>
    <p>ABC</p>
    <span>ABC</span>
  </li>
</ul>When I try to manage with onClick event I notice that target elements are sometimes a paragraph, sometimes a span. But I certainly need a li as a target element when I click on it or on tags inside it.
Advertisement
Answer
Use event.currentTarget instead of event.target – it always refers to the element you actually attached the listener to, not the element that the Event originally triggered on.