Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 233
Dan Avatar asked Nov 06 '12 11:11

Dan


People also ask

How to hide on scroll in jQuery?

scrollEnd(function(){ $('. main'). fadeIn(); }, 700);

How do I display the content while scrolling in HTML?

First wrap whatever your text or content that you want to show on scroll, in one div so that you can show hide the div depending upon the scroll. Write two classes for your target div. Hope it will solve your problem.


1 Answers

<div>
  <div class="a">
    A
  </div>
</div>​


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

Sample

like image 171
Priyank Patel Avatar answered Sep 24 '22 07:09

Priyank Patel