Last active
February 24, 2020 21:21
-
-
Save TonyDotDev/b67b02db129028f4428a456060b65674 to your computer and use it in GitHub Desktop.
Copy to clipboard javascript function.
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
function copyToClipboard(element) { | |
window.getSelection().removeAllRanges(); | |
const range = document.createRange(); | |
range.selectNode(element); | |
window.getSelection().addRange(range); | |
document.execCommand("copy"); | |
window.getSelection().removeAllRanges(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment