I'm using clipboard.js to copy some text from a textarea
, and that's working fine, but I want to show a tooltip saying "Copied!" if it was successfully copied like they do in the example given on their website.
Here's an example of it working without showing a tooltip: https://jsfiddle.net/5j50jnhj/
I am using Menucool JavaScript Tooltip. It leaves to the triggering element to decide how to launch the tooltip:
Here's a js fiddle that implements this the way the website does it, I stole the source code: https://jsfiddle.net/bmbs7yco/
the main components to the solution are:
and adding their primer.css. A less lazy method would be to extract the classes from the css you need.
This solution work, if you have some buttons and etc:
I do it like it
HTML :
JS :
With jsfiddle link https://jsfiddle.net/hs48sego/1/
Clipboard.js creator here. So Clipboard.js is not opinionated about user feedback which means it doesn't come with a tooltip solution.
But here's an example of how you can integrate it with Bootstrap's Tooltip.