<script type="text/javascript"> $(document).ready(function(){ var link = window.location.pathname; $('.nav li a[href="'+link+'"]').parents('li').addClass('active'); }); </script>