JS and Jquery can get the width of the page elements, height and relative displacement values, so that they can convert or replace each other, what is the difference in writing? This article will be introduced in detail for you.
1.Js get browser height and width
Document.documentElement.clientWidth ==> Browser Visible area width
Document.documentElement.clientHeight ==> Browser Visible area height
Document.body.clientWidth ==> Body Object width
Document.body.clientHeight ==> Body Object Height
JQ get browser height and width
$ (window). Width () ==> browser visible Area
$ (window). Height () ==> Browser visible Area Heights
$ (document). Height () ==> of the page document
$ (document.body). Height () ==> Body Object Heights
2.Js Get the height and width of the object
Obj.width = Obj.style.width
Obj.clientwidth = width + padding ==> obtains element widths including inner boundary (padding)
Obj.offsetheight = height + padding + border ==> get element Heights including inner boundary (padding) and border (border)
JQ Gets the height and width of the object
The Obj.innerwidth () ==> obtains the element width including the inner boundary (padding),
Obj.outerwidth () ==> Gets the width of elements including inner boundary (padding) and border (border)
Obj.outerwidth (True) ==> gets the width of an element that includes an outer boundary (margin)
W the same element should be: Width () <=innerwidth () <=outerwidth () <=outerwidth (true);
3.Js get the relative height and width of the object
Obj.offsetleft the ==> element relative to the left of the parent element
Obj.offsettop ==> elements relative to the top of the parent element
Obj.scrollwidth ==> Gets the scrolling width of an object
Obj.scrollheight ==> Gets the scrolling height of the object
Obj.scrollleft ==> Sets or gets the distance that is scrolled at the left end of an object
Obj.scrolltop ==> Sets or gets the distance that is scrolled at the top of the object
Jq gets the relative height and width of the object
Obj.offset (). Left ==> element relative to left of document
Obj.offset (). Top ==> element relative to top of document
Obj.scrollleft () ==> Sets or returns the offset of the object relative to the left of the scroll bar.
Obj.scrolltop () ==> Sets or returns the offset of the object relative to the top of the scroll bar.
The above mentioned is a small set of JS and JQ to get the browser and object value method, I hope to help!