Last active
July 21, 2024 00:02
-
-
Save toshimaru/6102647 to your computer and use it in GitHub Desktop.
Detect the scrolling to bottom of the page using jQuery.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).on("scroll", function() { | |
var scrollHeight = $(document).height(); | |
var scrollPosition = $(window).height() + $(window).scrollTop(); | |
if ((scrollHeight - scrollPosition) / scrollHeight === 0) { | |
// when scroll to bottom of the page | |
} | |
}); |
If you want to do it in a element scroll, you can do this:
// ...
var parent = $('#parent')
var child = $('#child')
parent.on("scroll", function() {
if (parent.scrollTop()+parent[0].offsetHeight-child[0].scrollHeight === 0) {
// when scroll to bottom of the page
}
});
Awesome, thanks. This should be the first result for anyone who is searching for 'detect scroll to botton of page using jquery'.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@areghunanyan thanks
I fixed little bit to work on ie too. this works fine for me.