The JavaScript implementation selects everything under the specified html tag and copies it.

Let me give you an example. Now you have the following code:

<body>
<div>
<span>hahaha</span>
<div id="select">
<span>hahahaha</span>
</div>
</div>
</body>

I need to select the content where id is select and keep the original format to copy to the clipboard. How can I do this under JavaScript? I have tried the select function, but it is only useful for input tags. How to implement it for non-input tags

Mar.20,2021

document.getElementById('select').innerHTML // idselect
Menu