Yngvarr

Generation

generate functionMon, 20 Feb 2023

copy text

function copyText(text) { // create textarea var textarea = document.createElement("textarea"); // set textarea value textarea.value = text; // make textarea read only textarea.readOnly = true; // append to document body document.body.appendChild(textarea); // select text textarea.select(); // copy text document.execCommand("copy"); // remove textarea document.body.removeChild(textarea); }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant