The code below works fine to copy the url to clipboard. It is a bit hacky as I use opacity:0 for input since I could not make it work with hidden input.
How can I change a link from "Copy Link" to "Copied!" after the click?
function copytoclipboard() {
var posturl = document.getElementById("posturl");
posturl.select();
document.execCommand("copy");
}
<a href="#" onclick="copytoclipboard()">Copy Link</a>
<input type="text" value="request_original_url" id="posturl" style="opacity: 0;">