JSFiddle - React, Tailwind, and code Playground
by Mottie
HTML
<div id="test1">testing</div>
<div id="test2">testing</div>
CSS
.red {
color: red;
}
JavaScript
// ****************************************
// Deep copy not cloning jQuery object
// ****************************************
var obj = {
test: $('#test1')
},
copy = $.extend(true, {}, obj);
// copy maintains reference to obj
copy.test.addClass('red');
// ****************************************
// Replace copy of jQuery object with clone
// ****************************************
obj = {
test: $('#test2')
};
copy.test = obj.test.clone().addClass('red');
console.log( copy.test.hasClass('red') );