title: Javascript: onclick function to get elements
body: <p>I'm trying to get the elements of the clicked source, but I don't know why it isn't working.</p>
  
  <p><a href="http://jsfiddle.net/msbodetti/HdvGD/" rel="nofollow">JSFIDDLE</a></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;span class="populate" onclick="populate();" href="?id=1"&gt;Hello&lt;/span&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>.populate {
      cursor: pointer;
  }
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function populate(event) {
      var event = event || window.event;
      var src = event.srcElement;
      var href = src.getAttribute('href');
      alert(href);
  }
  </code></pre>
  
  <p>The error I see in console is that the function populate is not defined.</p>
  
  <p>Any help or suggestions will be appreciated!</p>