0
I’ve created a menu that understands when the scroll
goes from a certain point and is fixed, until then everything right, but when I rolled the page a little lower, and updated (F5) I noticed that the menu is gone, and then when scrolling once the scroll up/down it reappears.
Does anyone know what I could do to make it not occur, pop up the tbm menu while giving a refresh/F5?
Follows code below.
$(document).ready(function(){
var div = $('#menu');
$(window).scroll(function () {
if ($(this).scrollTop() > 35) {
div.addClass("menu-fixo");
} else {
div.removeClass("menu-fixo");
}
});
});
#menu {
min-height: 112px;
background-color: tomato;
}
.menu-fixo {
position: fixed;
top: 0px;
left: 0;
right: 0;
z-index: 100;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="menusite" class="container-fluid">
<div class="row">
<div class="col-md-12"> Menu </div>
</div>
<div>
Do you have a URL to check this behavior? I imagine the script is being loaded or fired after the scroll happens, but I wanted to be sure before giving an answer
– Celso Bessa
@Celsobessa have no friend, is running local. The script is just that right there.
– AntonioSantos