1 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
2 jQuery.each([ "Height", "Width" ], function(i, name){
4 var tl = i ? "Left" : "Top", // top or left
5 br = i ? "Right" : "Bottom"; // bottom or right
7 // innerHeight and innerWidth
8 jQuery.fn["inner" + name] = function(){
9 return this[ name.toLowerCase() ]() +
10 num(this, "padding" + tl) +
11 num(this, "padding" + br);
14 // outerHeight and outerWidth
15 jQuery.fn["outer" + name] = function(margin) {
16 return this["inner" + name]() +
17 num(this, "border" + tl + "Width") +
18 num(this, "border" + br + "Width") +
20 num(this, "margin" + tl) + num(this, "margin" + br) : 0);
23 var type = name.toLowerCase();
25 jQuery.fn[ type ] = function( size ) {
26 // Get window width or height
27 return this[0] == window ?
28 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
29 document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
30 document.body[ "client" + name ] :
32 // Get document width or height
34 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
36 document.documentElement["client" + name],
37 document.body["scroll" + name], document.documentElement["scroll" + name],
38 document.body["offset" + name], document.documentElement["offset" + name]
41 // Get or set width or height on the element
43 // Get width or height on the element
44 (this.length ? jQuery.css( this[0], type ) : null) :
46 // Set the width or height on the element (default to pixels if value is unitless)
47 this.css( type, typeof size === "string" ? size : size + "px" );