Load content while scrolling a div with jquery

Posted by enfix on Stack Overflow See other posts from Stack Overflow or by enfix
Published on 2010-04-14T16:15:17Z Indexed on 2010/04/14 16:33 UTC
Read the original article Hit count: 760

I need to load content while scrolling a div, not window. That's my CSS code:

#sidebar{
 width:30%;
 float:right;
 height:455px;
}
#video_list{
  height:100%;
  overflow:auto;
}

And this is my html code:

<div id="sidebar" >
 <!-- other -->
 <div id="video_list">
 </div>
</div>

Video_list is scrollable and the content is loaded by ajax call. When I go to the end of scrollbar i need to load content again. How can i determine the height of scrollable div ? I tried this:

if ($("#video_list").scrollTop()==$("#video_list").height()){
  loadContent();
 }

but it doesn't work !

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about scrollbar