JSFiddle - React, Tailwind, and code Playground
HTML
<div id='test'>test
<div id='testp'>testp</div>
</div>
<div id='whatever'>whatever</div>
CSS
#test{border:red solid 2px;}
#newtest{background-color:aqua;}
JavaScript
var test = $("#test");
var newtest = test.clone(true, true);
newtest.find('#testp').remove();
newtest.attr('id', 'newtest');
newtest.appendTo("#whatever");