I've got a question about the following script:
function copyElementText(id) { var text = document.getElementById(id).innerText; var elem = document.createElement("textarea"); document.body.appendChild(elem); elem.value = text; elem.select(); document.execCommand("copy"); document.body.removeChild(elem); console.log('Copy made'); } <font id="text" onclick="copyElementText(this.id)">Copy this text</font> This script copies the text to the clipboard when you click on it.
I can only use this once. I need this multiple times in a HTML file. How can I adjust the script so I can use it more times?
Thanks!