/ Published in: JavaScript
look through the list items in your main nav and based on href of anchor tags this will set the top level link to have an 'active' class.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> $(document).ready(function(){ $(".sf-menu li").children("a").each(function() { if(window.location.href == $(this).attr('href')){ if($(this).parent().hasClass('main_link')){ $(this).addClass('active'); }else{ var topLink = $(this).parents('.main_link'); topLink.find('a').first().addClass('active') } } }); }); </script>