title: Assign src of image to a variable through JS in HTML
body: <p>I want to assign content of the src tag of image to a variable on clicking on the image through JS:
  Eg-</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div id="img"&gt;
  &lt;img src="image1.jpg"&gt;
  &lt;img src="image2.jpg"&gt;
  &lt;/div&gt;
  &lt;span id="source"/&gt;
  </code></pre>
  
  <p>JS
  ???</p>
  
  <p>I want to assign the image source of the clicked image to a variable and then display the source on HTML through span. This all should happen when I click the image. And the source that is going to be assigned to variable should be of the clicked image.</p>
  
  <p>How can I do it?</p>
  
  <p>Thanks in advance.</p>