Skip to content

Instantly share code, notes, and snippets.

@peacefulseeker
Last active November 27, 2017 15:48
Show Gist options
  • Save peacefulseeker/20d9df73bb7141f2aa1a17ad8dcf426d to your computer and use it in GitHub Desktop.
Save peacefulseeker/20d9df73bb7141f2aa1a17ad8dcf426d to your computer and use it in GitHub Desktop.
jQuery - Copy with JS on element click(Works well for pre + code tags)
/* Works well on pre + code tags. */
function copySelected() {
return document.execCommand('copy');
}
$("#element").on("click", function () {
setTimeout(function (argument) {
copySelected();
}, 100);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment