Skip to content

Instantly share code, notes, and snippets.

@charisTheo
Last active November 5, 2019 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charisTheo/ad749eee1a1bc7ed83c646b04f630847 to your computer and use it in GitHub Desktop.
Save charisTheo/ad749eee1a1bc7ed83c646b04f630847 to your computer and use it in GitHub Desktop.
A utility function for copying a string to the clipboard
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