Skip to content

Instantly share code, notes, and snippets.

@SebastianUdden
Created April 5, 2023 14:10
Show Gist options
  • Select an option

  • Save SebastianUdden/132126d1ba9fb19bbbed63bca7f5f656 to your computer and use it in GitHub Desktop.

Select an option

Save SebastianUdden/132126d1ba9fb19bbbed63bca7f5f656 to your computer and use it in GitHub Desktop.
Copy to clipboard
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