title: How to switch image based on anchor tag using jQuery?
body: <p>I have a lists of thumbnail images. When user clicks a small thumbnail image, it swaps it to show the full image.
  I have been trying to get the anchor tag name so that I can explode the value <code>i</code>. But I can't get it working, any ideas?</p>
  
  <p>My javascript:</p>
  
  <pre><code>function swap(image) {
     document.getElementById("main").src = image.href;
  }
  </code></pre>
  
  <p>My HTML &amp; PHP script:</p>
  
  <pre><code>&lt;img id="main" src="images/main.jpg" width="226" height="226" alt="" /&gt;
  
  &lt;p&gt;&lt;strong&gt;Day &lt;?php echo $i; ?&gt;:&lt;/strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;?php echo $today[$i]; ?&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;?php
   for($i=1; $i&lt;$day; $i++)
     {
       echo'&lt;a href="images/prevDay-'.$i.'.jpg" name="day-'.$i.'" onclick="swap(this); return false;"&gt;';
       echo'&lt;img src="images/thumbDay-'.$i.'.jpg" width="50" height="50" alt="" title="thumbDay-'.$i.'.jpg" /&gt;&lt;/a&gt; ';
     }
  ?&gt;
  </code></pre>