Skip to content

Instantly share code, notes, and snippets.

@fazlurr
Created August 11, 2015 08:15
Show Gist options
  • Save fazlurr/e66e0ca736068483a5f8 to your computer and use it in GitHub Desktop.
Save fazlurr/e66e0ca736068483a5f8 to your computer and use it in GitHub Desktop.
Copy to Clipboard Function - http://stackoverflow.com/a/30810322
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