How do I add 1px to the padding of a div element with jquery? The div element might have any amount of padding beforehand, and I want to increment the padding by 1px.
+1
A:
Get the old value, add one pixel to it, and assign it as the new value:
obj.css("padding", parseInt(obj.css("padding"))+1)
If your former padding value is not in pixels you will probably do some conversion first.
Gumbo
2010-02-27 07:46:01
isn't this missing the "px"?
Omar Abid
2010-02-27 08:51:47
this didn't work for me, but if instead of saying "padding", I did "paddingTop" etc, then it worked :)
Kyle
2010-02-27 18:30:03