html - How to get an element's padding value using JavaScript? -


i have textarea in html. need padding numerical value in pixels either integer or float. how can using javascript? not using jquery, i'm looking pure javascript solutions.

this return padding-left value:

window.getcomputedstyle(txt, null).getpropertyvalue('padding-left') 

where txt reference textarea element.

the above works in modern browsers , in ie9. however, not work in ie8 , below.

live demo: http://jsfiddle.net/simevidas/yp6xx/

further reading: https://developer.mozilla.org/en/dom:window.getcomputedstyle


btw, comparison, how same job done using jquery:

$(txt).css('padding-left') 

the above work in ie6-8.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -