neda Derakhshesh
neda Derakhshesh

Reputation: 1163

small alert for copy to clipboard in clipboard.js

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,

enter image description here

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

Answers (1)

Aslam
Aslam

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

Related Questions