Skip to content

Instantly share code, notes, and snippets.

@mircian
Created April 28, 2017 18:26
Show Gist options
  • Save mircian/5d8e3f8d3151fe821a55448859ae6c32 to your computer and use it in GitHub Desktop.
Save mircian/5d8e3f8d3151fe821a55448859ae6c32 to your computer and use it in GitHub Desktop.
<a href="javascript:void(0);" data-clipboard-text="This is the text to copy!" class="btn-copy">
<span class="m_copy_text">Copy Link</span>
</a>
var clipboard = new Clipboard('.btn-copy');
clipboard.on('success', function(e) {
var trigger = jQuery(e.trigger);
var text_span = trigger.find('.m_copy_text');
var text = text_span.text();
text_span.text('Copied!');
setTimeout(function () {
text_span.text(text);
}, 2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment