Currently, I am attempting to create a duplicate of a class and ensure that it remains unaffected when the original is altered. So far, I have tried:
$(".newclass").addClass("oldclass");
However, this method does not copy the content.
var _elementClone = $(".oldclass").html();
$(".newclass").html(_elementClone);
This approach successfully transfers all the contents of the div.
My problem arises when any changes are made to the parent class 'oldclass,' such as:
$('.oldclass').hide();
<style>
.oldclass{visibility:collapse}
</style>
In these instances, the new class also undergoes modifications. How can I create a new class that remains unchanged when alterations are made to its parent?