Firing An Event When The ScrollBar Reaches Webpage Bottom Using jQuery | jQuery Tutorial

The JavaScript code snippet below shows an alert message when the scroll bar hits the bottom of the page. The jquery scroll function will be fired every time we scroll the page. However, we restrict the logic to execute by putting this inside a conditional statement that determines the position of the scroll bar.
  if($(window).scrollTop() == $(document).height() - $(window).height() ){

    alert("reached bottom of the page");