Superfish vertical menu with active page

147 Views Asked by At

I am integrating super fish as a vertical menu. I would like the current page highlighted and it's submenu expanded via javascript. This looks like what I am looking for functionally http://jsfiddle.net/Zx2EU/3/, but I'm trying to append the active/current state via javascript, checking the page URL vs. the href. I found this code, but cannot implement it correctly:

var path = window.location.pathname.split('/');
path = path[path.length-1];
if (path !== undefined) {
  $("ul.sf-menu")
    .find("a[href$='" + path + "']") // gets all links that match the href
    .parents('li')  // gets all list items that are ancestors of the     link
    .children('a')  // walks down one level from all selected li's
    .addClass('current');
}

I started a jsfiddle, but I don't have access to https, so I can't link the external js and css: https://jsfiddle.net/7w27a5cc/

In this case, I am testing it with the navbar_3.html link in the second submenu to no avail.

Many thanks--

0

There are 0 best solutions below