开发者

Add 1px to padding of element with jquery

开发者 https://www.devze.com 2022-12-21 05:10 出处:网络
How do I add 1px to the pad开发者_如何学JAVAding 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.Get the old value,

How do I add 1px to the pad开发者_如何学JAVAding 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号