Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the maximum bottom value of scrollTop on a div?

Tags:

I need a way to automatically find the maximum bottom value of scrollTop, of the div id "#box".

Something like this: How to get maximum document scrolltop value

but just in a div, not the whole browser window. How can I do this?

like image 407
Jony Kale Avatar asked Jun 21 '13 21:06

Jony Kale


People also ask

How do I get scrollTop value?

To get or set the scroll position of an element, you follow these steps: First, select the element using the selecting methods such as querySelector() . Second, access the scroll position of the element via the scrollLeft and scrollTop properties.

What does scrollTop return?

scrollTop()Returns: Number. Description: Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.

What is scrollTop in angular?

ng-scrolltop demo: angular component that monitors current Y position in a long page or element then if scrolled down enough, shows up a clickable, unobtrusive icon that scrolls to top smoothly.

How do I know if my scroll is at the top?

You can check if window. scrollY (the number of pixels the window has scrolled vertically) is equal to 0 . If you want to check if the window has been scrolled to its leftermost, you can check if window. scrollX (the number of pixels the window has scrolled horizontally) is equal to 0 .


1 Answers

here you go:

var trueDivHeight = $('.someclass')[0].scrollHeight; var divHeight = $('.someclass').height(); var scrollLeft = trueDivHeight - divHeight; alert(scrollLeft); 

Simplified

like image 127
Neta Meta Avatar answered Sep 18 '22 15:09

Neta Meta