I am following this article http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation
I am able to successfully add a class to the active page li menu item but does anyone know how to modify or add to this script so that any parent menu li items also get the active class?
I would like to avoid having to add ID's as the menu items will be changing alot
My menus have three levels max
here is the script jquery script i am using
$(function(){
var path = location.pathname.substring(1);
if ( path )
$('.topLevel a[href$="' + path + '"]').attr('class', 'underline');
});
which works on the current page li a
I thought I could go this route
$('.topLevel a[href$="' + path + '"]').attr('class', 'underline').parent().attr('class', 'underline');
but it does not seem to work any ideas?
a working example can be found here