tags:

views:

27

answers:

1

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
isn't this missing the "px"?
Omar Abid
this didn't work for me, but if instead of saying "padding", I did "paddingTop" etc, then it worked :)
Kyle