js send copy to clipboard code example
Example 1: js copy string to clipboard
const el = document.createElement('textarea');
el.value = str; //str is your string to copy
document.body.appendChild(el);
el.select();
document.execCommand('copy'); // Copy command
document.body.removeChild(el);
Example 2: javascript copy to clipboard
var copyTextarea = document.getElementById("someTextAreaToCopy");
copyTextarea.select(); //select the text area
document.execCommand("copy"); //copy to clipboard