I want to get the bottom position of the visible part of the document, not the height of document.
For example, my screen height is 768px
then the height of visible part is about 650px
, if the scroll height is 200px
then the bottom position will be around 850px
. I tried using $(window).height()
but it returns the height of the document.
The offset bottom is calculating by using this statement “var bottom = el. offsetTop + $(el). outerHeight();” and calculated value is displaying.
We can use the getBoundingClientRect method to get an element's position relative to its viewport. We get the div with querySelector . Then we call getBoundingClientRect on it to get an object with the top and left properties. top has the position relative to the top of the viewport.
In order to get the location of an element relative to the document, jQuery offset() method is used. The offset() method is an inbuilt method in jQuery which is used to set or returns the offset coordinates of the selected element. We can also use the jQuery position() method.
Without jQuery
window.scrollY + window.innerHeight
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With