How to hide div at the end of vertical scroll
I have a div at the bottom of the screen at a fixed position with an arrow inside. How can I hide a div when the user scrolls to the bottom of the page?
+3
user2028327
source
to share
3 answers
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
$('div').hide();
}
});
+3
Chris visser
source
to share
Try the following:
var vericalscroll= document.height - (window.pageYOffset + window.innerHeight);
if yours vericalscroll
is 0, it means you rewrote at the end of the vertical scroll.
+2
Milind anantwar
source
to share
You can try jQuery for this:
var max_scroll = 500;
$(document).scroll(function(){
if($(this).scrollTop() >= max_scroll)
{
$('#my_div').fadeOut();
}
});
where my_div
is your div name and max_scroll
is the scrolled position.
0
Rahul
source
to share