how to create a button that copy's current url to clipboard in jquery code example
Example 1: javascript text to clipboard
function copyToClipboard(text) {
const elem = document.createElement('textarea');
elem.value = text;
document.body.appendChild(elem);
elem.select();
document.execCommand('copy');
document.body.removeChild(elem);
}
Example 2: js select and copy on click
document.getElementById("copy-text").onclick = function() {
this.select();
document.execCommand('copy');
alert(window.getSelection().toString());
}