Page 1 of 1

How To Calculate the Max ScrollTop value for a DIV

Posted: Tue Aug 02, 2016 4:35 pm
by Andy Parker

I have a DIV named "newschool_div" in a page called timesheets.
In that DIV I have a grid that is populated with rows of school names.
If the school name on a particular row is the one selected from a previous page it is coloured to highlight it.

Also, I am trying to set the div's scrollTop setting to make sure the selected school is visible on the div. I do this by setting the scrollTop element of the DIV to scroll the DIV to have the selected row visible.

My problem is, after a lot of reading and trying, the scrollHeight figure seems to bare no relation to the max scrollTop figure.

for example, by using the code below, the maxScrollTop comes back as 62522, but when I manually scroll the div to the bottom, the scrollTop figure is 3514.....

My question is, how can I calculate the maximum figure for scrollTop for the DIV? the figure should equal the figure I manually see when scrolling all the way to the bottom.....

code
var elem = $("#timesheets_newschool_div");
var maxScrollTop = elem[0].scrollHeight - elem.outerHeight();
/code


How To Calculate the Max ScrollTop value for a DIV

Posted: Sun Aug 07, 2016 7:57 am
by Serhii Kulibaba

Hello Andy,

Could you show on the screenshot, what do you mean with max ScrollTop? Is it the same as it is described here: http://stackoverflow.com/questions/12... ?