How to determine if a scrollable element has been scrolled to the bottom
$(element).scroll(function () {
var scrollH = $(this)[0].scrollHeight;
var clientH = $(this)[0].clientHeight;
var offset = scrollH - clientH;
if (offset == $(this).scrollTop()) {
/**
* action to perform when scrollable
* area hits bottom
*/
}
});
You would think something this simple would be easy to find.
I did test in the latest browsers for Chrome, Firefox, and Safari (sorry IE) on a Mac and it appears stable.
Should also mention that jQuery-1.9.1 was used to generate the example.
Written by Joaquin Senosiain
Related protips
2 Responses
Thanks for the tip, using syntax highlighting might make it easier to grok.
over 1 year ago
·
@posbo Thanks for the suggestion. Hope that helps.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#