Already a lot of things looked, I just can not understand what the error is. I have a menu that sticks to the screen and disappears when a footer appears. While trying to make it disappear just by scrolling down to the end.
var hght = 95; var mrg = 0; $(function(){ var elem = $('#menu'); var top = $(this).scrollTop(); $(window).scroll(function(){ top = $(this).scrollTop(); if ($(window).scrollTop() == $(document).height() - $(window).height()){ elem.hide(); } if (top+mrg < hght) { elem.css('top', (hght-top)); } else { elem.css('top', mrg); } }); });
Google how to determine scroll to the end
if ($(window).scrollTop() == $(document).height() - $(window).height()){ elem.hide(); }
But the element disappears only if you scroll down, then up again. It also worked if I wrote
if ($(window).scrollTop() == $(window).height()/3){ elem.hide(); }
But this is not correct, because then the code is tied to the size of the scroll and content. Please tell me how to do it right. Thank you in advance!