D7: jQuery script for creating 'active' links in menu system. (partially works) This is such a pity D7 does not have by default active links sets in the menu system. I mean everyone likes to have a clue where he is in the site by the active state of the menu.

I wonder why there is no such default feature in Drupal7?

Now I tried to do this in jQuery like this (see below) but it only works for predictable URL like static pages (it doesn't work for menu links created out of taxonomy terms). If someone can help me make it work for all the links in the menu I would appreciate.

  &lt;script type="text/javascript"&gt;
  /*Script for creating active links*/
  $(document).ready(function(){
   var currentURL = document.location.pathname;
   var activeTopLevelPageArray = currentURL.split('/');
   var activeTopLevelPage = activeTopLevelPageArray[1];

   // applying the class to what we find
   $('#header ul li a[href^=/'+activeTopLevelPage+']')
    .addClass('active');
   // now making the nav menu do what we want with styles for the active element
    $('#header #primary-menu ul li a.active:first')
    .addClass('current-main') // assign main active bg to active link
    .parent('li') // select the parent list item
      .addClass('active-trail'); // then assign a class to it for manipulation

    /* If there is no match, just activate the "home" menu item/tab */
    var isActive = $('#header #primary-menu li.active-trail').size();
    if (isActive &lt; 1) {
    $('#header #primary-menu li:first').addClass('active-trail');
    }
});
  &lt;/script&gt;
I'm pretty sure Drupal 7 does that for you out of the box. I can see, from my D7 site, I have first, last active-trail classes

&lt;ul class="menu"&gt;&lt;li class="first leaf"&gt;&lt;a href="/opportunities" title=""&gt;Opportunities&lt;/a&gt;&lt;/li&gt;
&lt;li class="leaf active-trail"&gt;&lt;a href="/organisations" title="" class="active-trail active"&gt;Organisations&lt;/a&gt;&lt;/li&gt;
&lt;li class="last leaf"&gt;&lt;a href="/events" title=""&gt;Events&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


As can be seen above the LI have the class you require. Do you have any custom code, modules or theme functions causing this not to happen on your site?