Search code examples
jqueryscrollshow-hide

Show/Hide Div on Scroll


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?


Solution

  • <div>
      <div class="a">
        A
      </div>
    </div>​
    
    
    $(window).scroll(function() {
      if ($(this).scrollTop() > 0) {
        $('.a').fadeOut();
      } else {
        $('.a').fadeIn();
      }
    });
    

    Sample