1

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 !

marcgg
  • 65,020
  • 52
  • 178
  • 231
enfix
  • 6,680
  • 12
  • 55
  • 80
  • what do you mean "it doesn't work". Do you get errors? Is the callback called? try to be more specific – marcgg Apr 14 '10 at 16:28

1 Answers1

0

To get the scroll height you can do this:

$("#video_list")[0].scrollHeight;

Erikk Ross
  • 2,173
  • 13
  • 18
  • OK, but don't work: $('#video_list').scroll(function (){ if($("#video_list").scrollTop()==$("#video_list")[0].scrollHeight){ loadContent(); } } ); – enfix Apr 14 '10 at 17:06
  • 1
    Ok i solve it. I have to sum with #sidebar height: if($("#video_list").scrollTop()+$("#sidebar").height()==$("#video_list")[0].scrollHeight) – enfix Apr 14 '10 at 17:10