I have this code to hide and show menu when scroll. How can i do it to appear class only of scroll >= than 500px. I have traied to ad a if (scroll >= 500) on code but it wont work.
jQuery(document).ready(function( $ ) {
// console.log($);
var lastScrollTop = 200;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
$('nav').addClass('nav-off');
$('nav').removeClass('nav-on');
} else {
$('nav').addClass('nav-on');
$('nav').removeClass('nav-off');
}
lastScrollTop = st;
});
});
2
Answers
last part of the code note working it overtakes 1'st part, and wont respect the 500px min height to add class.
This is the part that wont let the other to work. if i deleat it it only works at 500ps to show and to hide. The scroll to top part only should wolt when you scroll down 500px.
The Below Code Show Button while Scroll down more than 500px
When Scroll up it hide,
Hope its help
Screen Capture
Screen Capture
Your CSS would be using the same
and you could put two more for up and down for