Friday, October 12, 2012

Dynamic highlighting navigation menu

<script type="text/javascript">
        $(document).ready(function(){
        var str=location.href.toLowerCase();
        $("#yourmenuid li a").each(function() {
        if (str.indexOf(this.href.toLowerCase()) > -1) {
         $("a.active").removeClass("active");
        $(this).addClass("active");
        }
         });
         })

    </script>

2 comments:

  1. Bloody fool, There should be a ";" at the end of the code.

    ReplyDelete