I want to set something in the middle of the screen
thanks
height() method is recommended when an element's height needs to be used in a mathematical calculation. This method is also able to find the height of the window and document. $( document ). height();
$(document). height() returns an unit-less pixel value of the height of the document being rendered. However, if the actual document's body height is less than the viewport height then it will return the viewport height instead.
Use offsetWidth & offsetHeight properties of the DOM element to get its the width and height.
In jQuery, height method is used to get the height of any element in HTML. The height method sets and returns the height of the HTML elements. Method 1: The height() method returns the first matched element's height, But the height(value) method sets all matched elements height.
$(window).height(); // returns height of browser viewport $(document).height(); // returns height of HTML document
As documented here: http://api.jquery.com/height/
use with responsive website (view in mobile or ipad)
jQuery(window).height(); // return height of browser viewport jQuery(window).width(); // return width of browser viewport
rarely use
jQuery(document).height(); // return height of HTML document jQuery(document).width(); // return width of HTML document
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