Superfish is a jQuery plugin for creating drop down menu. You can download it @ GitHub – karevn / superfish.
It works well but there is no CSS class for identifying the menu item of the current page. Luckily i found a solution in StackOverflow.
The following jQuery code will find out the menu item which match the current URL and add the active class to it.
6 thoughts on “Superfish – Add active class to current menu link”
This solution doesn’t seems to work for me. Where exactly you have put this piece of code ? In your HTML file or JS file?
Have you included the jQuery lib?
This only works if all web pages are under the root of the project. If you nest pages within folders then this doesn’t work.
ie http://xxx.domain.com/default.html (works)
http://xxx.com/firm/about.html (does not work_
How about this?
Reference: StackOverflow – Superfish plugin tweak – adding a ‘current’ class to a parent li element too
This works for me, But is there a way to get the sub menu to auto expand if the page is active?
Can this script also expand the sub categories if the url is matched