Copy (CTRL + C) com JavaScript
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<input id="text" /> | |
<button id="copy">Copy</button> | |
<script type="text/javascript"> | |
const textInput = document.getElementById('text'); | |
const copyButton = document.getElementById('copy'); | |
copyButton.addEventListener('click', ()=> { | |
textInput.select(); | |
document.execCommand('copy'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment