Home  >  Article  >  Web Front-end  >  Accurate understanding of various heights of jQuery windows, documents, and web pages_jquery

Accurate understanding of various heights of jQuery windows, documents, and web pages_jquery

WBOY
WBOYOriginal
2016-05-16 16:42:421017browse

$(document).height(): The height of the entire web page
$(window).height(): The height of the browser’s visible window
$(window).scrollTop(): The height from the top of the browser’s visual window to the top of the web page (vertical offset)

To understand it in one sentence: when the scroll bar of the web page is pulled to the lowest end, $(document).height() == $(window).height() $(window).scrollTop().

When the height of the web page is less than the browser window, $(document).height() returns $(window).height().

It is not recommended to use heights such as $("html").height() and $("body").height().

Reason:

$("body").height(): The body may have a border, and the obtained height will be smaller than $(document).height();
$("html").height(): The meaning of the height obtained on different browsers will be different. To put it bluntly, the browser is incompatible.
There is something wrong with the $(window).height() value. What is returned is not the height of the browser window?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn