Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:42:42
Original
1017 people have browsed it

$(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?

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!