jQuery addClass Issue - trying to find an element by ID
<p>I have a menu which links to anchors on the page. There are a couple of additional pages that can also link back to the home page with these anchors on.</p>

<p>I have some jQuery which changes the color of a menu item when it clicked. So if I click on About on the homepage, it goes to the about anchor and highlights about in blue. If I click on about from the blog page though, it goes to the home page, and the about anchor but it doesn't   highlight the menu item as that jQuery is only triggered by a click event. I am trying to therefore manually trigger the highlight when page loads if it sees an anchor in the URL.</p>

<p>The HTML is:</p>

<pre><code>&lt;ul id="navigation"&gt;
  &lt;li id="item_0"&gt;&lt;a href="#home" class="active"&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;li id="item_1"&gt;&lt;a href="#about"&gt;About&lt;/a&gt;&lt;/li&gt;
  &lt;li id="item_2"&gt;&lt;a href="#projects"&gt;Projects&lt;/a&gt;&lt;/li&gt;
  &lt;li id="item_3"&gt;&lt;a href="#locate"&gt;Locate&lt;/a&gt;&lt;/li&gt;
  &lt;li id="item_4"&gt;&lt;a href="/blog"&gt;Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>As you can see - the class="active" is applied to &lt; a> tag of the active menu item.</p>

<p>I'm trying to use the following jQuery JS to check on page load for anchor tags, and highlight the relevant one.</p>

<pre><code>$(document).ready(function(){
    var hash = window.location.hash;

    switch(hash){
        case "#about":
            $('#navigation li a').removeClass("active");
        $('item_1', '#navigation li a').addClass('active');
         break;
    }
});
</code></pre>

<p>Can anyone help with whats going wrong?</p>

<p>Thanks in advance for your help!</p>
