title: Detecting anchors with Jquery?
body: <p>I want to know if it's possible to have the script detect the URL anchor, and load content specific to that anchor. For instance, I have this line of code:</p>
  
  <p><code>&lt;a href="#home"&gt;&lt;span id="homeMenu"&gt;Home&lt;/span&gt;&lt;/a&gt;</code></p>
  
  <p>This line of code listens to this code:</p>
  
  <pre><code>$("#homeMenu").click(function () {
      $("#home_content").show("slow");
      $("#accommodations_content").hide("slow");
      });
  </code></pre>
  
  <p>How could I make it that if the user visits <code>http://www.myurl.com/home.html#home</code> that it loads the home content automatically. This should also work for all other anchors that I would want to implement.</p>
  
  <p>I want this because, right now, if the user visits any of the anchors directly, no mater which anchor, it will always display the home page. So, is there a way to detect which URL is loaded and then run a script on that?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So,currently it ONLY loads accommodations (even when on the #Home)</p>
  
  <p>Current code:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt; 
              $(document).ready(function() {
              document.getElementById("javascriptCheck").style.visibility = 'hidden';
              $("#menu").load("snippets/menu.html");
              $("#locationMenu").load("snippets/locationMenu.html");
              $("#home_content").load("snippets/home_content.html");
              $("#accommodations_content").load("snippets/accommodations.html");
              $("#history").load("snippets/history.html");
              $("#footer").load("snippets/footer.html");
  
              var hash = window.location.hash;
              if (hash = "#Home") {
                  $("#home_content").show("slow");
                  $("#accommodations_content").hide("slow");
              }
              if (hash = "#Accommodations") {
                  $("#accommodations_content").show("slow");
                  $("#home_content").hide("slow");     
              }
              } );
          &lt;/script&gt; 
  </code></pre>