Click button copy to clipboard using jQuery

前端 未结 21 2125
醉话见心
醉话见心 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:05

    It's very important that the input field does not have display: none. The browser will not select the text and therefore will not be copied. Use opacity: 0 with a width of 0px to fix the problem.

提交回复
热议问题