javascript api copy to clipboard code example
Example 1: js copy to clipboard
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);
}