开发者

jQuery active menu issue

开发者 https://www.devze.com 2022-12-14 10:45 出处:网络
I have tried to implement this jQuery active menu code: http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation

I have tried to implement this jQuery active menu code: http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation

 $(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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消