Reputation: 16024
Can you use the .width()
and .height()
methods to increase the height like $('x').width('+=2px')
or $('x').height('+=2px')
?
I couldn't find any information about this on the jQuery website, but I also haven't seen anything to suggest that this doesn't work.
Upvotes: 1
Views: 674
Reputation: 34778
Why not just do something like this?
var el = $('x');
el.width(el.width()+2);
EDIT: To clean it up, you can create a plugin, something like this (untested):
jQuery.fn.increaseWidth = function(amount) {
this.width(this.width()+amount);
return this;
};
This would allow you to do $('x').increaseWidth(2)
Upvotes: 2
Reputation: 11563
These methods get and set the height or width of the elements.
width()
or width(val)
Such approach as you say is only provided on .animate()
Sinan.
Upvotes: 2
Reputation: 14816
No. The value you pass to width()
is expected to be a CSS length value. Pixels are assumed if you don't specify a unit.
Upvotes: 1