Created
April 5, 2023 14:10
-
-
Save SebastianUdden/132126d1ba9fb19bbbed63bca7f5f656 to your computer and use it in GitHub Desktop.
Copy to clipboard
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 copyToClipboard = (value) => { | |
| const body = document.body; | |
| const storage = document.createElement("textarea"); | |
| storage.value = value; | |
| body.appendChild(storage); | |
| storage.select(); | |
| storage.setSelectionRange(0, 99999); | |
| document.execCommand("copy"); | |
| body.removeChild(storage); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment