(Hope it is not a duplicate because I didn\'t find it when searching and googling)
I am trying to find how to detect in some fixed-height div (\'#div\') when the scroll-
In the .height() documentation:
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
In your case it sounds like you may want the height of the document
rather than the window
. Think of it this way: The window
height is what you see, but the document
height includes everything below or above.
EXAMPLE
EDIT:
Checking for top and bottom on scroll with help from the scrollTop() method:
var bottom = $(document).height() - $(window).height();
$(document).scroll(function(){
var position = $(this).scrollTop();
if (position === bottom) {
console.log("bottom");
}else if(position === 0){
console.log("top");
} else {
console.log("scrolling");
}
});