JSFiddle - React, Tailwind, and code Playground
HTML
<div id="a"></div>
<div id="b" style="padding:10px;"></div>
JavaScript
//alert(document.getElementById('a').style.padding);
//alert(document.getElementById('b').style.padding);
var stylePart = getStyle(document.getElementById("a"), "padding-right");
alert(stylePart);
function getStyle(oElm, strCssRule) {
var strValue = "";
if (document.defaultView && document.defaultView.getComputedStyle) {
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
}
else if (oElm.currentStyle) {
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1) {
return p1.toUpperCase();
});
strValue = oElm.currentStyle[strCssRule];
}
return strValue;
}