Created
April 23, 2015 19:00
-
-
Save wtfaremyinitials/1b16346f0458dd6e8dda to your computer and use it in GitHub Desktop.
Javascript copy to clipboard
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 copytext(text) { | |
var textField = document.createElement('textarea'); | |
textField.innerText = text; | |
document.body.appendChild(textField); | |
textField.select(); | |
document.execCommand('copy'); | |
textField.remove(); | |
} | |
// credit to reddit.com/u/liamht |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work (Firefox 48 /Win7)