JSFiddle - React, Tailwind, and code Playground

HTML

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

CSS

#box{
    width:200px;
    height:10%;
    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;
}
    

var b = document.getElementById('box');

b.onclick = function() {
    this.style.display = 'none';
    var height = getStyle('box', 'height');
    this.style.display = '';
    this.innerHTML = height;
}