S
S
Sergey2018-02-12 14:48:57
JavaScript
Sergey, 2018-02-12 14:48:57

How to calculate the height from the beginning of the body to the bottom edge of the last block (or element) in it?

How to calculate the height from the beginning of the body to the bottom edge of the last block (or element) in it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2018-02-12
@byte916

On js - first we get the coordinates relative to the browser window, then we add the window scroll to them.

var rect = el.getBoundingClientRect();
var top = rect.top + document.body.scrollTop;
var left = rect.left + document.body.scrollLeft;

jquery
$(el).offset();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question