user1469270
user1469270

Reputation:

User reaches bottom of page. Elements fade out?

I've made a single page website.

Is there a Jquery snippet that can understand when the user has reached the bottom of the page, and certain elements to then fade out accordingly?

Upvotes: 0

Views: 164

Answers (2)

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67197

You should have to use the window's scroll event in order to find whether user has reached the bottom of the document. Please refer the following piece of code to accomplish your requirement,

$(window).scroll(function(){ 
   if( $(window).scrollTop() == ($(document).height() - $(window).height()) )
      {
      }
});

For your understanding, scrolltop is the top value of the window, it might change from 0 to document's height - window's height. so we could easily identify the end point by checking this case. Hope this will help you.

Upvotes: 1

Andrew Clody
Andrew Clody

Reputation: 1181

http://api.jquery.com/offset/

The .offset() method allows us to retrieve the current position of an element relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent.

Upvotes: 0

Related Questions