<script>
jQuery(function (jQuery) {
// jQuery('#menu:first-child li').addClass('xx-menu-active');
jQuery(window).scroll(function () {
var scrollPos = jQuery(window).scrollTop();
jQuery('.xx-section').each(function (i) {
var topPos = jQuery(this).offset().top;
if ((topPos - scrollPos) <= 180) {
jQuery('.xx-menu-active').removeClass('xx-menu-active')
jQuery('#menu li').eq(i).addClass('xx-menu-active')
}
})
});
});
</script>
This code will add or remove a CSS class on a menu item that is an anchor link. To be used on a single page navigation menu. Each section needs to be given the class .xx-section.