I'm trying to create a deep copy of a div. What I mean is that when the cloned copy of the div changes color, then the original div should change color as well.
What happens in the clone or in the original, should also happen in other one. Here's a JsFiddle
let clonedEle = $(".one").clone();
clonedEle.insertAfter(".one");
$(".one").click(function() {
$(this).css("background-color", "blue");
});
.one {
background-color: red;
width: 50px;
height: 50px;
margin-bottom: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="one">
</div>
My goal is to get both divs blue when we click either one. In this example, only one of the divs becomes blue when you click on them instead of both at the same time. How do I achieve this?