I am currently in the process of transferring an outdated application to a new platform, but I'm facing difficulty understanding the changed JavaScript code.
My goal is to find a parent HTML element named "output" and then select all its child elements as if they were highlighted by the user.
Once that is done, I want to be able to copy this selection to the clipboard.
Despite my efforts, I haven't been able to find a satisfactory solution online for the initial task, and I'm concerned that even if I do solve it, there might still be obstacles with the second part.
If anyone has suggestions on how to achieve this, your help would be greatly appreciated.
EDIT: The HTML content is dynamically generated, hence I have provided a simplified version here instead of the actual layout.
<div id="output">
<h1>My Name</h1>
<img src="" />
</div>
What I aim to do is highlight the displayed HTML (excluding the outer HTML) and then copy it to the clipboard.
The copied result should resemble the following:
My Name
And not like this:
<div id="output"><h1>My Name</h1><img src="" /></div>
I have considered using JavaScript range for this task, but I'm unsure about how to select all the contents of the parent element "output".