Posts Tagged ‘navigation’

jQuery Highlight Navigation Menu v.02 Script

I have found a simpler way to add class=”selected” to any navigation menu by checking your URL path against links on the page. I’ve only tested this with page slugs in wordpress. But it works very nicely.

// Highlight Tab v.02 by Jake Rutter
// Website: http://www.onerutter.com
// Feel free to use and adapt, please just give credit where credit is due.
        jQuery(document).ready(function(){
             var path = location.pathname;
              jQuery("a[href$='" + path + "']").addClass("selected");
     });

|