tags:

views:

35

answers:

1

Hi Team,

I have tried to implement this jQuery active menu code: http://docs.jquery.com/Tutorials%3AAuto-Selecting%5FNavigation

 $(function(){
   var path = location.pathname.substring(1);
   if ( path )
     $('#sidebar_content a[@href$="' + path + '"]').attr('class', 'selected');
 });

but it does not seem to be adding the class: http://www.thecreativealliance.org/gallery/advertising-and-marketing?CategoryID=39196&cat=Promotions%20%26%20publicity

Any ideas?

Jack

A: 

Try .addClass('selected') (documentation) and change the query: #sidebar_content a[href="' + ... (@ and $ aren't needed).

JQuery API doc is highly recommended, to keep in mind the available methods.

culebrón
Thanks Culebron. I get the following error in firebug: uncaught exception: Syntax error, unrecognized expression: [@href$="gallery/education-and-knowledge"]
Jackson
@ and $ aren't needed. Remove them and it must work.
culebrón