title: jQuery "window.location.hash" - getting hash too late?
body: <p>I'm working on some script but it have a serious problem with hashes.</p>
  
  <p>I have a list of link-images like:</p>
  
  <pre><code>&lt;a href="#1"&gt;&lt;img src="1.jpg" /&gt;&lt;/a&gt;
  &lt;a href="#1"&gt;&lt;img src="2.jpg" /&gt;&lt;/a&gt;
  &lt;a href="#1"&gt;&lt;img src="3.jpg" /&gt;&lt;/a&gt;
  </code></pre>
  
  <p>All I want to do is to load file files/#1.html after clicking the first image, files/#2.html after the second etc.</p>
  
  <p>Here's my jQuery function:</p>
  
  <pre><code>$("a img").click(
  function()
  {  
          var hash = window.location.hash;
          $("#displayFile").load('files/'+ hash +'.html');
          $("#displayFile ").fadeIn(300);  
   });  
  </code></pre>
  
  <p>So when I click a image it should add hash to the url (href="#1"), load the right file to #displayFile div and fade it in.</p>
  
  <p>But actually when I click the image it shows empty #displayFile div and after i refresh the site with the same hash it loads the content. I believe the script gets the hash long before it's in URL.</p>
  
  <p>How to fix it?</p>
  
  <p>Thanks.</p>