Check if page scroll is at bottom

May seem odd to check if the page scroll is at bottom, but can be useful if you need to hide something or show something else, as in a back to top button for example.

$('#back-to-top').hide();
$(window).scroll(function(){
    if ( document.body.scrollHeight - $(this).scrollTop()  <= $(this).height() ){
        $('#back-to-top').show();
    } else {
        $('#back-to-top').hide();
    }
});

Comments

  1. written by: talip on October 25, 2017 at 11:18 am - Reply

    thanks ,it worked .

Leave a Reply

Your email address will not be published. Required fields are marked *

− 4 = 4

This site uses Akismet to reduce spam. Learn how your comment data is processed.