JSFiddle - React, Tailwind, and code Playground
Performing surgery on a clone of some existing DOM nodes
by Admiral Potato
HTML
<div id="a">
<h1>Title</h1>
<h2>SubTitle</h2>
<p>Descriptions of massive proportions</p>
</div>
<div id="b"></div>
CSS
*{
font-family: sans-serif;
}
#a, #b{
padding: 8px;
background-color: #fcc;
}
#b{
background-color: #ccf;
}
JavaScript
var incomingHtml = $('#a').html();
var $tempDiv = $('<div>').html(incomingHtml);
$tempDiv.find('h2').remove();
$('#b').html($tempDiv.html());