JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test"></div>
IE 9.0.8112 on Windows 7 returns false when testing the font size.
CSS
#test {
/* In a real world example this would be a relative font-size */
font-size: 3.14px;
}
JavaScript
// http://robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/ (cosmetic changes)
function getStyle(el, prop) {
var val = null;
if (document.defaultView && document.defaultView.getComputedStyle) {
val = document.defaultView.getComputedStyle(el, null).getPropertyValue(prop);
} else if (el.currentStyle) {
prop = prop.replace(/\-(\w)/g, function (strMatch, p1){
return p1.toUpperCase();
});
val = el.currentStyle[prop];
console.log(val);
}
return val;
}
// RegExp from jQuery source
var rnumpx = /^-?\d+(?:px)?$/i;
// Test case
var el = document.getElementById('test'),
fontSize = getStyle(el, 'font-size');
console.log(fontSize, rnumpx.test(fontSize));