Suppose I have the following HTML snippet:
<style>
#testSubject{
color: red;
width: 200px;
}
</style>
<p id="testSubject">Hello, world!</p>
With jQuery / vanilla JS, is there any way to save the currently active styling of the element to a variable, so that it may be restored/used later?
ie: var testSubjectStyles = $('#testSubject').css('*');
now I have the variable testSubjectStyles
, and can apply those stylings to any element.
Is it possible to do this? I've been playing around with jQuery's .css()
, but that only seems to let you set stylings.