title: How to change HTML text with Javascript using event object
body: <p>I can't understand why e.target.name is showing undefined even though e.target returns the node. How would I simply change the text using the event object?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function changeText(e) {
    console.log(e.target, e.target.name);
    
    switch (e.target.name) {
      case 'fooBar':
        e.target.innerHTML = 'bar';
        break;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
    &lt;p name="fooBar" onclick="changeText(event)"&gt;foo&lt;/p&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>