jQuery “active” class assignment for the parent
<p>i have this html in my main navigation:</p>

<pre><code>&lt;div id="navigation"&gt;  
  &lt;ul&gt;
     &lt;li&gt;
       &lt;a href="/contact"&gt;contact us&lt;/a&gt;
     &lt;/li&gt;
   &lt;li&gt;
      &lt;a href="/projects"&gt;projects&lt;/a&gt;       
   &lt;/li&gt;
  &lt;/ul&gt;
 &lt;/div&gt;
</code></pre>

<p>i wanted to mark the active link, so i use this jquery:</p>

<pre><code>$("div#navigation").find("a[href='" + top.location.pathname + "']").each(function ()
 {
   $(this).addClass("active")
 })
</code></pre>

<p>while its working good for URL's like domain.com/projects or domain.com/contacts,<br>
i have a problem for deepers URL's, lets take for example domain.com/projects/proj-1.<br>
i want that when i go to deeper URL, it will mark as active the parent URL (domain.com/projects).  how can i do that?</p>

<p>Thanks!</p>
