JSFiddle - React, Tailwind, and code Playground
JavaScript
getStyle = function (el, prop) {
if (getComputedStyle !== 'undefined') {
return getComputedStyle(el, null).getPropertyValue(prop);
} else {
return el.currentStyle[prop];
}
}
// Create paragraph element and append some text to it
var p = document.createElement('p');
p.appendChild(document.createTextNode('something for fun'));
// Append element to the body
document.getElementsByTagName('body')[0].appendChild(p);
// Set hex color to this element
p.style.color = '#f99';
// alert element's color using getStyle function
alert(getStyle(p, 'color'));