I need to save the innerHTML of a parent element to a variable while ignoring certain child classes.
I've tried hiding and displaying none (doesn't work). Removing them and then adding them back in to the place that they were may be an option but am unsure of how to achieve that.
Example code, read the innerHTML of the parent div, but ignore any element containing "ignore-me" as a class.
<div id="parent">
<p>read me read me read me</p>
<div class="ignore-me">and thus ignore this text</div>
<p>read me read me read me</p>
<script class="ignore-me"></script>
<p>read me read me read me</p>
<link class="ignore-me">
</div>
I have a copy button which copies the content of the body to clipboard. I just need to figure out how to ignore/strip the above elements from the copy function without destroying them.