Click button copy to clipboard using jQuery

前端 未结 21 2082
醉话见心
醉话见心 2020-11-21 23:11

How do I copy the text inside a div to the clipboard? I have a div and need to add a link which will add the text to the clipboard. Is there a solution for this?

         


        
21条回答
  •  旧巷少年郎
    2020-11-22 00:01

    you can just using this lib for easy realize the copy goal!

    https://clipboardjs.com/

    Copying text to the clipboard shouldn't be hard. It shouldn't require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn't depend on Flash or any bloated framework.

    That's why clipboard.js exists.

    or

    https://github.com/zeroclipboard/zeroclipboard

    http://zeroclipboard.org/

    The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.

提交回复
热议问题