Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get bottom position of current viewport on browser

Tags:

html

jquery

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.

like image 464
Hoàng Lập Avatar asked May 31 '16 08:05

Hoàng Lập


People also ask

How do I find the offset on my bottom?

The offset bottom is calculating by using this statement “var bottom = el. offsetTop + $(el). outerHeight();” and calculated value is displaying.

How do you get Element top position relative to the browser's viewport?

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.

How do I find the position of an element in Windows?

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.


1 Answers

Without jQuery

window.scrollY + window.innerHeight
like image 127
asdillon29 Avatar answered Sep 21 '22 23:09

asdillon29