Skip to content

Instantly share code, notes, and snippets.

@onigetoc
Created July 17, 2016 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onigetoc/f85f97e352bac05fd401b8b037c00a05 to your computer and use it in GitHub Desktop.
Save onigetoc/f85f97e352bac05fd401b8b037c00a05 to your computer and use it in GitHub Desktop.
Copy to clipboard Javascript - copyToClipboard
// copy to clip board
$("#copy").click(function() {
copyToClipboard('#allContent');
});
function copyToClipboard(element) {
var $temp = $("<textarea>");
$("body").append($temp);
$temp.val($(element).html()).select();
document.execCommand("copy");
$temp.remove();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment