Created
August 31, 2019 20:00
-
-
Save mohdovais/f9124c4ad23731a61543dbcee8a10f3e to your computer and use it in GitHub Desktop.
copy text to clipboard in browser
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(text){ | |
var textarea = document.createElement('textarea'); | |
textarea.value = text; | |
document.body.appendChild(textarea); | |
textarea.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(textarea); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment