In short, is there a way to set the outerWidth?
$.outerWidth(true, newValue)
Update: I found some addons that do this, although I need one function definition not 3 addons to do this.
You were pretty close. With jQuery 1.8+, just use:
.outerWidth(newValue, true);
Also works for:
.innerWidth(val)
.innerHeight(val)
.outerWidth(val [, true])
.outerHeight(val [, true])
It actually became a setter with jQuery 1.8. That is 1 year after you posted your question. Moreover, it was listed in the changelog, but nobody updated the documentation which explains that it might have been missed by many.
If you have jQuery 1.7.2 or older, see Xeo's answer (on this page) or use jquery-ui 1.8.4+ which automatically enhances those methods into getters/setters (since in jQuery 1.8, those methods were actually ported from jquery-ui).
Is this what you're looking for?
var a = $('element');
actualWidth = a.outerWidth(true),
desiredWidth = 1000,
difference = desiredWidth - actualWidth,
a.css('width',difference);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With