title: Implementing scroll in a DIV
body: <p>I have this Javascript code below. This helps me to gain infinite scroll in a webpage. What if i want to implement that infinite scroll in a DIV. How can i modify this code to use it inside a DIV? 
  can anyone please help me. <em>Say the id of my DIV is #wrapper in which the scroll content is to be displayed</em></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $(window).scroll(function(){
              if($(window).scrollTop() == $(document).height() - $(window).height()){
                  $('div#loadmoreajaxloader').show();
                  $.ajax({
                      url: "loadmore.php?lastid=" + $(".postitem:last").attr("id"),
                      success: function(html){
                          if(html){
                              $("#postswrapper").append(html);
                              $('div#loadmoreajaxloader').hide();
                          }else{
                              $('div#loadmoreajaxloader').html('&lt;center&gt;No more posts to show.&lt;/center&gt;');
                          }
                      }
                  });
              }
          });
      &lt;/script&gt;
  </code></pre>