title: Javascript attach event to class name
body: <p>If I have 10 items, with the class name <code>keyword</code>:</p>
  
  <pre><code>&lt;div class="keyword"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>How can I attach an event, for example <code>click</code>, on this element.</p>
  
  <p>I tried the following, but with no luck: (no alert comes up)</p>
  
  <pre><code>document.getElementsByClassName('.keyword').onclick = function()
  {
      alert(true);
      Search.addKey(this.getElementsByClassName('name')[0].innerHTML);
  }
  </code></pre>
  
  <p>Requirements:</p>
  
  <ul>
  <li>Without the onclick attribute</li>
  <li>no jQuery or any other library</li>
  </ul>
  
  <p>Note: the elements are not generated on page load. Their number can be different, each times you click a button for eg.</p>
  
  <p>I need a way to attach to all tags with the class 'keyword' in the 'future'.</p>