JSFiddle - React, Tailwind, and code Playground
by lchau
HTML
<div id="elementA" />
<div id="elementB" />
CSS
.a-style { background-color: red; }
.b-style { background-color: blue; }
JavaScript
var elementA = document.getElementById("elementA");
var elementB = document.getElementById("elementB");
if (typeof elementA == "undefined"
|| typeof elementB == "undefined") {
return;
}
elementA.className = "a-style";
var widthA = elementA.offsetWidth;
elementB.className = "b-style";
var widthB = elementB.offsetWidth;