after click a button .btn, I would like to copy a href atrribute on a clipboard.
here is the html source(clipboard.js recognize any type as button)
<a class="btn" href="#oops"><h1>Button</h1></a>
and below is the script:
<script type="text/javascript">
new Clipboard(".btn", {
text: function(trigger) {
return $(trigger).getAttribute("href");
}
});
</script>
But I cannot make it work successfully. If someone would help me a second i would be very grateful.
It works for me
new Clipboard('.btn', {
text: function (trigger) {
return trigger.getAttribute('href');
}
});
<script src="//cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.4.0/clipboard.min.js"></script>
<a class="btn" href="#oops"><h1>Button</h1></a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With