-
-
Save nocodesupplyco/a5a83ad77815280560125a5685db7430 to your computer and use it in GitHub Desktop.
Click to Copy to Clipboard
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
<!-- Example HTML with the "data-clipboard-text" attribute which holds the content to be copied --> | |
<div class="copy-btn" data-clipboard-text="28A745">Copy the attribute</div> | |
<!-- Place this before the end of the </body> --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script> | |
<script> | |
var clipboard = new Clipboard('[data-clipboard-text]'); | |
clipboard.on('success', function(e) { | |
console.log(e); | |
$('.copy-btn').click(); | |
}); | |
clipboard.on('error', function(e) { | |
console.log(e); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment