JSFiddle - React, Tailwind, and code Playground
HTML
<a id="myAnchor" title="smarty@pants.com" href="#">smarty@pants.com</a>
JavaScript
function myFunction() {
var copyText = document.getElementById("myAnchor").title;
document.addEventListener('copy', function(event) {
event.clipboardData.setData('text/plain', copyText);
event.preventDefault();
document.removeEventListener('copy', handler, true);
}, true);
document.execCommand('copy');
alert("Copied: " + copyText);
}
document.getElementById('myAnchor').addEventListener('click', myFunction);