title: How to get current element in getElementsByClassName
body: <p>Consider a simple JS event of</p>
  <pre><code>document.getElementsByClassName('test')[0].onclick=function(){
  document.getElementsByClassName('test')[0].innerHTML = 'New Text';
  }
  </code></pre>
  <p>How can I extend this code to generally work for all elements with <code>class=&quot;test&quot;</code>. I mean getting the element clicked and replace its content. In fact, we need to get the node number (provided inside the bracket) from the click event.</p>
  <p>I am trying to better understand Javascript in unobtrusive codes, not a practical method like jQuery.</p>