Created
August 11, 2015 08:15
-
-
Save fazlurr/e66e0ca736068483a5f8 to your computer and use it in GitHub Desktop.
Copy to Clipboard Function - http://stackoverflow.com/a/30810322
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
var copyMergeWordsResultBtn = document.getElementById('button-copy-merge-words-result'); | |
copyMergeWordsResultBtn.addEventListener('click', function (event) { | |
var mergeWordsResultTextarea = document.getElementById('merge-words-result'); | |
mergeWordsResultTextarea.select(); | |
try { | |
var successful = document.execCommand('copy'); | |
var msg = successful ? 'successful' : 'unsuccessful'; | |
console.log('Copying text command was ' + msg); | |
} catch (err) { | |
console.log('Oops, unable to copy'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment