Last active
November 5, 2019 18:09
-
-
Save charisTheo/ad749eee1a1bc7ed83c646b04f630847 to your computer and use it in GitHub Desktop.
A utility function for copying a string to the clipboard
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
const copyToClipboard = function(str) { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
alert('Link copied to clipboard!') | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment