title: Trigger action when reaching a target div in Javascript
body: <p>I am outputting a result set with PHP and MySQL, each result wrapped in a DIV. A JavaScript function triggers an action as soon as the user scrolls to the bottom of the browser window.</p>
  
  <pre><code>$(window).scroll(function(){
    if ($(window).scrollTop() == $(document).height() - $(window).height()){
      trigger_funtion();
    }
  }); 
  </code></pre>
  
  <p>Each item (class ".item") of the PHP result is placed into a general wrapper DIV (class ".results") containing all items.</p>
  
  <p>How can I change this function above so that the action is triggered as soon as the user "scrolls" or "arrives" at the last DIV which was created from the result set, rather than when he hits the bottom of the browser window?</p>
  
  <p>I have tried the following, but it does not work</p>
  
  <pre><code>$(window).scroll(function(){
    if  ($(window).scrollTop() == $(".results .item:last")){
      trigger_funtion();
    }
  }); 
  </code></pre>