copy a text js code example
Example 1: copy text to clipboard javascript
//As simple as this
navigator.clipboard.writeText("Hello World");
Example 2: javascript copy to clipboard
function copyToClipboard(text) {
var input = document.body.appendChild(document.createElement("input"));
input.value = text;
input.focus();
input.select();
document.execCommand('copy');
input.parentNode.removeChild(input);
}