3

I have a div at the bottom of the screen in fixed position with an arrow inside. How do I hide the div when the user has scrolled to the bottom of the page?

Stefan Rasmusson
  • 5,445
  • 3
  • 21
  • 48
user2028327
  • 39
  • 1
  • 2

3 Answers3

3
$(window).scroll(function() {
   if($(window).scrollTop() + $(window).height() == $(document).height()) {
       $('div').hide();
   }
});
Chris Visser
  • 1,607
  • 12
  • 24
2

Try this:

var vericalscroll= document.height - (window.pageYOffset + window.innerHeight);

if your vericalscroll is 0,it means you have reched at the end of vertical scroll.

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
Rahul
  • 395
  • 1
  • 15