title: Display image with JQuery
body: <p>I'm trying to get this code to work. Pretty much if the URL has #leaf in it then the  tag updates to display image2.png. I'm not sure what I'm doing wrong. </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("#image").show("fast") {
    // Which anchor is being used?
    switch(window.location.hash) {
       case "#leaf":
         window.location.href = image1.png
       break;
       case "#carrot":
         window.location.href = image2.png
       break;
    }
  });
  &lt;/script&gt;
  &lt;a href="#leaf"&gt;Leaf&lt;/a&gt;
  &lt;a href="#carrot"&gt;Carrot&lt;/a&gt;
  &lt;img id="image" /&gt;
  </code></pre>
  
  <p><strong>PS:</strong> I'm open to better ways of achieving this. Just tried the following but still doesn't work. </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $("#image").show("fast", function() {
      // Which anchor is being used?
      switch(window.location.hash) {
      case "#leaf":
          $(this).attr('src', 'image1.png');
          break;
      case "#carrot":
          $(this).attr('src', 'image2.png');
          break;
    }
  });
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;a href="#leaf"&gt;Leaf&lt;/a&gt;
  &lt;a href="#carrot"&gt;Carrot&lt;/a&gt;
  &lt;img id="image" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>