Skip to content

Instantly share code, notes, and snippets.

@lankaapura
Created January 29, 2018 09:58
Show Gist options
  • Save lankaapura/6d6413f82a1d07dc3b7fc4d13b95f118 to your computer and use it in GitHub Desktop.
Save lankaapura/6d6413f82a1d07dc3b7fc4d13b95f118 to your computer and use it in GitHub Desktop.
<!-- 1. Define some markup -->
<div id="btn" data-clipboard-text="1">
<span>Copy</span>
</div>
<!-- 2. Include library -->
<script src="clipboard.min.js"></script>
<!-- 3. Instantiate clipboard by passing a HTML element -->
<script>
var btn = document.getElementById('btn');
var clipboard = new Clipboard(btn);
clipboard.on('success', function(e) {
console.log(e);
});
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