Show/Hide Div on Scroll

Dan picture Dan · Nov 6, 2012 · Viewed 122.7k times · Source

I have a div that sits at the bottom of a slideshow that I want to disappear when the user scrolls or uses down arrow then reappears when scrolls back to the top. I am guessing this is incorporating the jquery scroll functionality?

Answer

Priyank Patel picture Priyank Patel · Nov 6, 2012
<div>
  <div class="a">
    A
  </div>
</div>​


$(window).scroll(function() {
  if ($(this).scrollTop() > 0) {
    $('.a').fadeOut();
  } else {
    $('.a').fadeIn();
  }
});

Sample