JSFiddle - React, Tailwind, and code Playground
HTML
<div id="div1" onclick="Dimension(this.id);">click on this</div>
CSS
div {
height:20px;
margin:7px;
}
JavaScript
function Dimension(elmID) {
var elmHeight, elmMargin;
if (document.all) { // IE
elmHeight = document.getElementById(elmID).currentStyle.height;
elmMargin = parseInt(document.getElementById(elmID).currentStyle.marginTop, 10) + parseInt(document.getElementById(elmID).currentStyle.marginBottom, 10) + "px";
}
else { // Mozilla
elmHeight = document.defaultView.getComputedStyle(document.getElementById(elmID), '').getPropertyValue('height');
elmMargin = parseInt(document.defaultView.getComputedStyle(document.getElementById(elmID), '').getPropertyValue('margin-top')) + parseInt(document.defaultView.getComputedStyle(document.getElementById(elmID), '').getPropertyValue('margin-bottom')) + "px";
}
alert("Height=" + elmHeight + "\nMargin=" + elmMargin);
}