How to get an element’s padding value using JavaScript?

Spread the love

To get an element’s padding value using JavaScript, we call the getComputedStyle method.

For instance, we write

window.getComputedStyle(txt, null).getPropertyValue("padding-left");

to call getComputedStyle to get the conmputed style of the txt element.

And then we call the getPropertyValue method to get the padding-left style.

Leave a Reply

Your email address will not be published.