jQuery.fn.css = function( name, value ) {
return jQuery.access( this, name, value, true, function( elem, name, value ) {
- jQuery.css( elem, name, value );
+ return jQuery.css( elem, name, value );
});
};
value += "px";
}
- if ( !("set" in hooks) || (value = hooks.set( elem, value )) === false ) {
+ if ( !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
style[ name ] = value;
}
} else {
- if ( "get" in hooks && (ret = hooks.get( elem, force, extra )) !== false ) {
+ if ( !force && "get" in hooks && (ret = hooks.get( elem, force, extra )) !== undefined ) {
return ret;
- }
- if ( !force && name in style ) {
+ } else if ( !force && style[ name ] ) {
ret = style[ name ];
- } else if ( curCSS ) {
+ } else if ( force !== false && curCSS ) {
ret = curCSS( elem, name, origName );
}
jQuery.each(["height", "width"], function( i, name ) {
jQuery.cssHooks[ name ] = {
get: function( elem, force, extra ) {
+ var val;
+
if ( elem.offsetWidth !== 0 ) {
val = getWH( elem, name, extra );
val = getWH( elem, name, extra );
});
}
+
+ return val + "px";
},
set: function( elem, value ) {
// ignore negative width and height values #1599
- elem.style[ name ] = Math.max( parseFloat(value), 0 ) + "px";
+ value = parseFloat(value);
+
+ if ( value >= 0 ) {
+ return value + "px";
+ }
}
};
});
} else if ( document.documentElement.currentStyle ) {
curCSS = function( elem, name ) {
- var left, rsLeft, ret = elem.currentStyle[ name ];
+ var left, rsLeft, ret = elem.currentStyle[ name ], style = elem.style;
// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
jQuery.each( which, function() {
if ( !extra ) {
- val -= parseFloat(jQuery.css( elem, "padding" + this, undefined, true)) || 0;
+ val -= parseFloat(jQuery.css( elem, "padding" + this, undefined, true )) || 0;
}
if ( extra === "margin" ) {
- val += parseFloat(jQuery.css( elem, "margin" + this, undefined, true)) || 0;
+ val += parseFloat(jQuery.css( elem, "margin" + this, undefined, true )) || 0;
} else {
- val -= parseFloat(jQuery.css( elem, "border" + this + "Width", undefined, true)) || 0;
+ val -= parseFloat(jQuery.css( elem, "border" + this + "Width", undefined, true )) || 0;
}
});