I have a div that is in the middle of the page, I need to trigger a function when the scrollbar gets 100px before the bottom of a DIV.
I played with all the combinations using
$(window).scrollTop();
$(document).height()
$('div').height();
but I can't get there.
Thanks for any help.
You can use this. Works in jsfiddle
$(window).scroll(function() {
var divTop = $('#yourDivId').offset().top,
divHeight = $('#yourDivId').outerHeight(),
wHeight = $(window).height(),
windowScrTp = $(this).scrollTop();
if (windowScrTp > (divTop+divHeight-wHeight-100)){
alert('reached');
}
});