JSFiddle - React, Tailwind, and code Playground
HTML
<a href="https://www.google.com">Copy me</a>
<button onclick="copyMe()">Copy</button>
JavaScript
copyMe = function() {
getSelection().removeAllRanges();
var range = document.createRange();
range.selectNodeContents(document.querySelectorAll("a")[0]);
getSelection().addRange(range);
document.execCommand("copy");
}