JSFiddle - React, Tailwind, and code Playground

by stecb

HTML

<div id="box">box</div>

CSS

#box{
    width:200px;
    height:200px;
    left:10%;
    position:absolute;
    background:red;
}

JavaScript

function getStyle(el,styleProp){ //from ppk's quirksmode
    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;
}
    

console.log(getStyle('box','left'));