$(document).scroll(function() { var scroH = $ (document) .scrollTop (); // Roll Height var viewH = $ (window) .height (); // visible height var contentH = $ (document) .height (); // height content if (scroH> 100) {// from the top is larger than 100px } if (contentH - (scroH + viewH) <= 100) {// is smaller than the height from the bottom 100px } if (contentH = (scroH + viewH)) {// scroll bar to the bottom it } });