开发者

How do you change the padding of an element in jQuery?

开发者 https://www.devze.com 2023-02-01 10:20 出处:网络
I am using the following code $(\"#numbers a\").css({ \"color\":\"whit开发者_StackOverflowe\", \"text-decoration\":\"none\",

I am using the following code

$("#numbers a").css({
"color":"whit开发者_StackOverflowe",
"text-decoration":"none",
"padding:":"5px"
});

The color and text-decoration change just fine, but the padding is not added to the element. How should I fix this?


You have a stray colon in your padding property which is causing it to not be recognized:

"padding:":"5px"

Remove it and it should work:

"padding":"5px"


In the : is just a typo in to your post, you might be confused with padding and inline elements.

Your selector "#numbers a" hints you are referencing an anchor tag. An anchor tag is an inline element and inline elements do not have padding on all sides. Nice article on padding|widths with inline elements

0

精彩评论

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

关注公众号