tags:

views:

14

answers:

1

Hello,

I would like to highlight the current page in the sidebar menu. I am using the foll. jquery script to do this. When I test the jquery script in the console window in firebug, it works.

When I upload the script to the website http://depts.washington.edu/uwbg/gardens/horticulture.php, it does not highlight the current page (except for a couple of pages). I've looked at similar postings on this forum, but could not figure out a solution that worked for my site. Any help appreciated. Thanks.

$(document).ready( function () {
var path = location.pathname;
if ( path )
 $('#section_navigation ul li a[href$="' + path + '"]').attr('class', 'current');
 }); 
A: 

When the above script is executed the menu which you are populating via an ajax call has not completed. Therefore the selector matches no elements. Put the code above in the callback of your menu ajax function (inside jquery_loadSectionNav.js) and it should work better!

redsquare
Thanks a million! That works.
Shruti