3 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
4 jQuery.each([ "Height", "Width" ], function( i, name ) {
6 var type = name.toLowerCase();
8 // innerHeight and innerWidth
9 jQuery.fn["inner" + name] = function() {
11 parseFloat( jQuery.css( this[0], type, "padding" ) ) :
15 // outerHeight and outerWidth
16 jQuery.fn["outer" + name] = function( margin ) {
18 parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
22 jQuery.fn[ type ] = function( size ) {
23 // Get window width or height
26 return size == null ? null : this;
29 if ( jQuery.isFunction( size ) ) {
30 return this.each(function( i ) {
31 var self = jQuery( this );
32 self[ type ]( size.call( this, i, self[ type ]() ) );
36 return jQuery.isWindow( elem ) ?
37 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
38 elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
39 elem.document.body[ "client" + name ] :
41 // Get document width or height
42 (elem.nodeType === 9) ? // is it a document
43 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
45 elem.documentElement["client" + name],
46 elem.body["scroll" + name], elem.documentElement["scroll" + name],
47 elem.body["offset" + name], elem.documentElement["offset" + name]
50 // Get or set width or height on the element
52 // Get width or height on the element
53 parseFloat( jQuery.css( elem, type ) ) :
55 // Set the width or height on the element (default to pixels if value is unitless)
56 this.css( type, typeof size === "string" ? size : size + "px" );