jQuery to Highlight the Current Menu Item

4 Sep

Here is a little bit of jQuery code to highlight the current menu item. This presumes you are using a UL > LI > A structure to build your menu.

<script type="text/javascript">
  $(document).ready(function() {
    var path = location.pathname;
  $("li:has(a[href$='" + path + "'])").addClass("selected");  });
</script>

No comments yet

Leave a Reply