JSFiddle - React, Tailwind, and code Playground
by naveen
HTML
<div id="blah"></div>
<div id="me">test</div>
CSS
#blah {
padding: 5px;
width: 200px;
height: 20px;
border: 1px solid #333;
font-family: "Verdana";
}
#me {
position: absolute;
left: 5px;
top: 5px;
}
JavaScript
CloneStyle("blah", "me");
$('#me').css({ background: 'blue' });
function CloneStyle(sourceID, targetID){
var myStyle;
var source = document.getElementById(sourceID);
var target = document.getElementById(targetID);
if (window.getComputedStyle) {
myStyle = window.getComputedStyle(source).cssText;
}
else if (source.currentStyle) {
myStyle = $.extend(true, {}, source.currentStyle);
} else {
throw "antique browser. pass to grandson";
}
target.style.cssText = myStyle;
}