Last active
November 27, 2017 15:48
-
-
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)
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
/* 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