1

For some reason I cannot get this scrollTop to behave like I would expect. Why is it returning 0. The first two calls to outerheight and scrollheight return 250 which is the pixel height of the col. My intention is to have the user scroll down while reading some legal text. I need to constantly check in realtime what the position of the scrollbar is when the user moves it. I cant seem to figure out how to attach an event to the scrollbar when its moved and then update the current position relative to the height of the containing div.. I need to know how many pixels from the top the scrollbar is.

The checkbox selected together with the scrollbar being down at the bottom must both be true, so what i need is to detect the position of the scrollbar to know if its at the bottom. I have seen tutorials online about how to do this but they deal with the whole page being scrollable, what I am looking for is just a div being scrollable and a way to detect its position.

var col = $('.inner');

col.outerHeight();//250

col.get(0).scrollHeight; //250

col.scrollTop(); //0

thanks,

jam
  • 3,640
  • 5
  • 34
  • 50
Rogelio
  • 77
  • 1
  • 9

1 Answers1

0

Try these posts:

How do I determine height and scrolling position of window in jQuery?

http://www.yelotofu.com/2008/10/jquery-how-to-tell-if-youre-scroll-to-bottom/

Community
  • 1
  • 1
Chris Pietschmann
  • 29,502
  • 35
  • 121
  • 166
  • That was the first place I went to but this solution didnt work. This part: `if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight())` elem.scrollTop always returns 0.. this is my problem. Its always going to be true... so therefore its always going to say that its at bottom.. – Rogelio Sep 08 '11 at 04:59