I'm trying to copy an anchor element (title) using onclick. This fires but doesn't copy the value. Any thoughts?
I know it's very rudimentary but, well, that's me.
<a id="myAnchor" onclick="myFunction()" title="smarty@pants.com" href="#">smarty@pants.com</a>
<script>
function myFunction() {
var copyText = document.getElementById("myAnchor").title;
document.execCommand("Copy");
alert("Copied the text: " + copyText.value);
}
</script>