JSFiddle - React, Tailwind, and code Playground

by Gabriele Petrioli

HTML

<div id="test">i am the text</div>

JavaScript

var test = document.getElementById('test');

alert( getStyle('test', 'line-height' ) );

function getStyle(el,styleProp)
{
    var x = document.getElementById(el);
    if (x.currentStyle)
        var y = x.currentStyle[styleProp];
    else if (window.getComputedStyle)
        var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
    return y;
}