I want to get the entire HTML from a element in HTML, I'm doing like this:
const divider = $('#divider').html()
$('#htmlElement').innerHTML = divider
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="divider">
<span>Test</span>
</div>
<span id="htmlElement"></span>
But it returns the children element from the <div></div>
, not the entire HTML selected by the id.
How can I get the entire HTML text from the selected element using jQuery? Including his class and all inlined styles?