From ee0175c4b9d665322ac496dfcc6f8b0cc70b3c35 Mon Sep 17 00:00:00 2001 From: John Resig Date: Wed, 10 Jan 2007 16:40:32 +0000 Subject: [PATCH] Added back in height and width - they now behave more appropriately. --- src/jquery/jquery.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 4543b72..401fd14 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -2109,3 +2109,71 @@ jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){ return this.filter( ":" + n + "(" + num + ")", fn ); }; }); + +/** + * Get the current computed, pixel, width of the first matched element. + * + * @example $("p").width(); + * @before

This is just a test.

+ * @result 300 + * + * @name width + * @type String + * @cat CSS + */ + +/** + * Set the CSS width of every matched element. If no explicit unit + * was specified (like 'em' or '%') then "px" is added to the width. + * + * @example $("p").width(20); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @example $("p").width("20em"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name width + * @type jQuery + * @param Number|String val Set the CSS property to the specified value. + * @cat CSS + */ + +/** + * Get the current computed, pixel, height of the first matched element. + * + * @example $("p").height(); + * @before

This is just a test.

+ * @result 300 + * + * @name height + * @type String + * @cat CSS + */ + +/** + * Set the CSS width of every matched element. If no explicit unit + * was specified (like 'em' or '%') then "px" is added to the width. + * + * @example $("p").height(20); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @example $("p").height("20em"); + * @before

This is just a test.

+ * @result

This is just a test.

+ * + * @name height + * @type jQuery + * @param Number|String val Set the CSS property to the specified value. + * @cat CSS + */ + +jQuery.each( [ "height", "width" ], function(i,n){ + jQuery.fn[ n ] = function(h) { + return h == undefined ? + ( this.length ? jQuery.css( this[0], n ) : null ) : + this.css( n, h.constructor == String ? h : h + "px" ); + }; +}); -- 1.7.10.4