I made this code so that when I rolled the page the MENU would be fixed in the Top. That is, always the view of the user.
var nav = $('#outermainmenu');
var lia = $('.sf-menu > li, .sf-menu > li > a');
$(window).scroll(function () {
if ($(this).scrollTop() > 440) {
nav.addClass("menu-fixed");
lia.addClass("menu-fixed");
} else {
nav.removeClass("menu-fixed");
lia.removeClass("menu-fixed");
}
});
This code above works. But only when the height is greater than 440px, since it is the height of my slider. But I wish it were not so. Why have pages that my slider changes height.
I do not want to be checking in my script for the height of the slider and defining a scrollTop.
How can I do this by checking if the menu is in TOP 0? The menu is after the 440px height slider.