title: Change image source with JavaScript
body: <p>So I'm new with JavaScript (this is actually my first attempt to make something work) and I'm having a bit of trouble. I thought I had enough knowledge to make this work, I've even googled for tutorials and scripts that could help me work this out but nothing really helped.</p>
  <p>I can't seem to change the image source, heres the code that I have so far:</p>
  <pre class="lang-js prettyprint-override"><code>    function changeImage(a) {
          document.getElementById(&quot;img&quot;).src=a.src;
      }
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>    &lt;div id=&quot;main_img&quot;&gt;
          &lt;img id=&quot;img&quot; src=&quot;1772031_29_b.jpg&quot;&gt;
      &lt;/div&gt;
      &lt;div id=&quot;thumb_img&quot;&gt;
          &lt;img src='1772031_29_t.jpg'  onclick='changeImage(&quot;1772031_29_b.jpg&quot;);'&gt;
          &lt;img src='1772031_55_t.jpg'  onclick='changeImage(&quot;1772031_55_b.jpg&quot;);'&gt;
          &lt;img src='1772031_53_t.jpg'  onclick='changeImage(&quot;1772031_53_b.jpg&quot;);'&gt;
      &lt;/div&gt;
  </code></pre>
  <p>Could anyone please explain if I'm doing something wrong? Or maybe I'm missing something? Help me please :-)</p>