I need to copy the text that is inside of ~p~ tag, I've tryed using this code:
HTML:
<p id="copy">Text to copy</p>
<button onclick="copyFunction()">Copy text</button>
JS:
function copyFunction() {
   var textToCopy = document.getElementById("copy");
   textToCopy.select();
   document.execCommand("copy");
   alert("Copied the text: " + textToCopy.value);
}
But it didn't worked.
 
     
     
     
    