scroll to bottom jquery not working properly

I have simple on code to see if bottom of page is reached alert. but its not working as I wanted.

I scroll down and come again to top, then is showing alert box. below is the code.

$(document).ready(function () {
    $(window).scroll(function () {
        if ($(window).scrollTop() + $(window).height() == $(document).height()) {
            alert("bottom!");
        }
    });
});

Answers


I finally came with this solution

$(window).scroll(function() {
  if (document.body.scrollHeight ==  document.body.scrollTop +  window.innerHeight) {
       alert("bottom!");

 }
});

Need Your Help

How do I find out what type each object is in a ArrayList<Object>?

java generics reflection arraylist

I have a ArrayList made up of different elements imported from a db, made up of strings, numbers, doubles and ints. Is there a way to use a reflection type technique to find out what each type of d...

Can I modify the url that is constructed from ui-router?

angularjs angular-ui-router

I'm currently using ui-router to manage my routes in my angularjs app, and I was wondering if there was a way to modify the url that gets created.