JavaScript
x
6
1
function copy(){
2
var email = "abc@dfg.ca";
3
email.select();
4
document.execCommand("Copy");
5
};
6
The above code does not copy the email address.
Advertisement
Answer
Check the snippet, this may help you
JavaScript
1
5
1
function copyEmail(){
2
var email = document.getElementById('email');
3
email.select();
4
document.execCommand('copy')
5
};
JavaScript
1
2
1
<input type="email" id="email"/>
2
<input type="button" value="copy" onClick="copyEmail()"/>