$('.menuanchor').on('click',function(e) { e.preventDefault(); var offset = 100; var target = this.hash; if ($(this).data('offset') != undefined) offset = $(this).data('offset'); $('html, body').stop().animate({ 'scrollTop': $(target).offset().top - offset }, 500, 'swing', function() { }); }); $(window).scroll(function(e) { var scroller_anchor = $(".scroller_anchor").offset().top; if ($(this).scrollTop() >= scroller_anchor && $('#optionsNAV').css('position') != 'fixed') { $('#optionsNAV').css({ 'background-color': 'rgba(255,255,255,0.95)', 'border': '1px solid #000', 'position': 'fixed', 'top': '60px', 'z-index':'999', }); $('#optionsNAV').addClass('fx-menu'); $('.scroller_anchor').css('height', '50px'); } else if ($(this).scrollTop() < scroller_anchor && $('#optionsNAV').css('position') != 'relative') { $('.scroller_anchor').css('height', '0px'); $('#optionsNAV').removeClass('fx-menu'); $('#optionsNAV').css({ 'background': '#FFF', 'border': '1px solid #CCC', 'position': 'relative' }); } });