title: How do I get the id of a clicked parent element in a card?
body: <p>I'm trying to make certain "cards" that display next to each other, and when the card is clicked, I want to get the id of the card. However, my function gets the id of the child elements when I click it, which is undefined, rather than of the parent card, unless I click on the border of the card div. How do I make sure it gets the id of the card specifically?</p>
  
  <p>Here is the HTML:</p>
  
  <pre><code>&lt;div id="parentCard" onclick="getID(event)"&gt;
    &lt;div id="child1"&gt;I'm a child&lt;/div&gt;
    &lt;div id="text"&gt;
      &lt;p&gt;Text 1&lt;/p&gt;
      &lt;p&gt;Text 2&lt;/p&gt;
      &lt;p&gt;Text 3&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>function getID(event){
    console.log(event.target.id);
  }
  </code></pre>