my js string looks like this ‘coolstring’
i want to output this string in html like this ‘cool string’
when i copy this string in the browser and paste it, in a word document for example, the whitespace should not copied -> coolstring
i tried different approaches according to this site: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace
2
Answers
The space can be in a pseudo element so will show but as it isn’t in the DOM it will not be copied:
You can replace the default copyText event for a specific element. More info about copyText here
Here’s the code working in a codepen demo
the demo only shows it on a div element, but it works on paragraphs and headers aswell