title: retrieve getAttribute of clicked element in javascript
body: <p>i have number of images on my webpage.</p>
  
  <pre><code>&lt;img id="a" src="1.jpg"&gt;
  &lt;br&gt;
  &lt;img  id="b" src="2.jpg"&gt;
  </code></pre>
  
  <p>I am trying to get "src" of clicked images by using below javascript.</p>
  
  <pre><code>var getImageName = function(){
       document.onclick = function(){
          var image = this.getAttribute("src");
          alert(image);
          }}
  
  getImageName();
  </code></pre>
  
  <p>But its giving an error this.getAttribute is not function.</p>
  
  <p>Any idea?
  Thanks in advance</p>