Created
July 18, 2019 16:02
-
-
Save emersonbrogadev/c2aa20d1d0070b807273cdaa50dff315 to your computer and use it in GitHub Desktop.
Copy (CTRL + C) com JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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