I have a called
spn1
, which has some style from inline + CSS file.
I have another called
spn2
Try using this:
document.getElementById("spn2").style = document.getElementById("spn1").style;
If you just want the CSS, you can do the following:
let cssText = document.defaultView.getComputedStyle( $("#elementID"), "").cssText;
Then you can apply that to any new element.
jQuery doesn't have any direct facilities for doing this. You will have to use plain old JavaScript to find a cross-browser way to copy over the computed style of one element to another. This answer has an implementation for a potential solution.