Tooltip on click of a button

后端 未结 7 1003
执笔经年
执笔经年 2021-01-01 20:31

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 copi

7条回答
  •  爱一瞬间的悲伤
    2021-01-01 21:08

    CSS Only Solution

    Githubs Primer tooltips is an excellent solution.

    Usage:

    npm install --save primer-tooltips
    

    Copy the node_modules/primer-tooltips/build/build.css file to a convenient location and then link to it in your HTML. (Consider renaming it a more convenient name e.g. primer-tooltips.css). You'll have to edit the build.css file by commenting out the .tooltipped:hover::before,.tooltipped:hover::after, pseudo selectors to achieve the on click effect.

    Assuming you have clipboardJS already set up, add the following attributes to your copy button:

    
    

    That's it!

提交回复
热议问题