Reputation: 1163
I have an Email address in my page and I want when user clicks on it, then the Email address would be copied to the clip board and with small alert(like attached) it shows user in a small label near the box that it copied to clipboard,
I used https://clipboardjs.com/ to implement my goal. it copied to clipboard fine, but the problem is that it doesn't show user that it copied to clipboard after clicks on it,
my code if needed:
javascript
new Clipboard('.btn');
html
<button class="btn" data-clipboard-text="[email protected]">
[email protected]
</button>
Appreciate any suggestion
Upvotes: 0
Views: 6121
Reputation: 9680
Actually, the tooltip is not a part of the clipboard.js
. If you look at the source code of the page, you can see that tooltip.js
is been added and configured in demo.js
.
All you need to do is add a tooltip library or function just like the demo page and use it on button click.
Hope it helps.
Upvotes: 1