I am using the following code
$("#numbers a").css({
"color":"white",
"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?
The innerWidth() method returns the inner width of the FIRST matched element.
jQuery outerWidth() Method The outerWidth() method returns the outer width of the FIRST matched element. As the image below illustrates, this method includes padding and border.
The jQuery CSS methods allow you to manipulate CSS class or style properties of DOM elements. Use the selector to get the reference of an element(s) and then call jQuery css methods to edit it. Important DOM manipulation methods: css(), addClass(), hasClass(), removeClass(), toggleClass() etc.
To get an element's padding value using JavaScript, we can use the getComputedStyle and getPropertyValue methods.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With