[Solved] Javascript for a suggestion box that pops up as the user scrolls down the screen. [closed]


You don’t need a plugin. Try something like this jQuery:

$(document).ready(function() {

  //Check to see if the window is top if not then display button
  $(window).scroll(function() {
    if ($(this).scrollTop() > 100) {
      $('.nextPost').fadeIn();
    } else {
      $('.nextPost').fadeOut();
    }
  });
});
.nextPost {
  background: lightgray;
  font-weight: bold;
  position: fixed;
  top: 5px;
  right: 5px;
  display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="nextPost">Next Post</div>

<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>

1

solved Javascript for a suggestion box that pops up as the user scrolls down the screen. [closed]