Created
August 24, 2022 14:26
-
-
Save leandromoh/c674a85d22a94b67101144c2aa26d75f to your computer and use it in GitHub Desktop.
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
(function copyStringToClipboard (str) { | |
var el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style = {position: 'absolute', left: '-9999px'}; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
})("text to be copied to clipboard") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment