Copy text to clipboard

Hello everyone,

I just want to copy the text inside a variable or the text of an text element to the clipboard using JavaScript from Wix Code.
Can someone please tell me how I can do that?

To copy to clipboard you need to access the document.execCommand and you canät reach that in Wix Code.

/* Copy the text inside the text field */
document.execCommand("Copy");

You might be able to do a workaround by putting that into a HTML Component and then send the value into the component and then use code there to copy to clipboard.