I`m trying to copy a div html content to another element as a text , but when I try that it ignores the white spaces, any idea how that can be done?
here is my code:
HTML
<div id="parent">
<!-- Component: -->
<div id="component" class="">
<p class="px-8 text-center py-2 bg-green-500 text-white
dark:bg-green-50 dark:text-green-900
font-medium text-lg rounded-md
hover:scale-105 hover:bg-green-100
">
Start Now
</p>
</div>
<!-- Code: -->
<div class="px-8 my-8">
<h1 class="text-white ">Code:</h1>
<p class="text-white" id="code"></p>
</div>
</div>
JS
const component = document.getElementById("component")
const code = document.querySelector("#code")
code.innerText=component.innerHTML
What I get: What I get
What I want: what I want