Text inserted via pseudo-elements like ::before and ::after cannot be selected or copied.
Is there a way to change this behavior?
span::before {
content: "including this text";
}
<p>
When the text of this paragraph is selected and copied, all of it should be copied.
<span>Not just part of it</span>.
</p>
I need a solution that does not involve JavaScript, but I am open to using acceptable JavaScript solutions, such as:
- a function that retrieves the text inserted via ::before for a given element.
- a function that sets the display of the ::before text for an element to none.