function copy(){ var email = "[email protected]"; email.select(); document.execCommand("Copy"); };
The above code does not copy the email address.
Answer
Check the snippet, this may help you
function copyEmail(){ var email = document.getElementById('email'); email.select(); document.execCommand('copy') };
<input type="email" id="email"/> <input type="button" value="copy" onClick="copyEmail()"/>