开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜