Created
June 18, 2020 20:19
-
-
Save codedrops-io/29ec3bde829d263e82f644931a168721 to your computer and use it in GitHub Desktop.
Simple copy to clipboard function.
This file contains hidden or 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
const copyTextToClipboard = (textString) => { | |
const textarea = document.createElement('textarea') | |
textarea.value = textString | |
document.body.appendChild(textarea) | |
textarea.select() | |
document.execCommand('copy') | |
document.body.removeChild(textarea) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment