I'm looking for a suitable way to copy URL (link) to the clipboard.
Can someone tell me how this can be achieved?
function copyURL() {
var elem = document.createElement("textarea");
document.body.appendChild(elem);
elem.value = google.com;
elem.select();
document.execCommand("copy");
document.body.removeChild(elem);
document.write("Copied to clipboard!");
}
<a href="javascript:void(1);" onclick="copyURL()">Copy URL</a>