Let's say that a web page is twice the height of the browser window (thus there's a scroll bar). How do I retrieve the height of the web page in jQuery?
jQuery height() Method The height() method sets or returns the height of the selected elements. When this method is used to return height, it returns the height of the FIRST matched element. When this method is used to set height, it sets the height of ALL matched elements.
$(window). resize(function() { // This will execute whenever the window is resized $(window). height(); // New height $(window). width(); // New width });
The height() is an inbuilt method in jQuery which is used to check the height of an element but it will not check the padding, border and margin of the element. Syntax: $("param").height() Parameters : This function do not accept any parameter. Return value : It returns height of the selected element.
Answer: Use the JavaScript height() method You can set the height of a <div> box dynamically using the jQuery height() method.
$(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document
You could use the height()
of the document.
$(document).height();
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