Click button copy to clipboard using jQuery

前端 未结 21 2081
醉话见心
醉话见心 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-21 23:58

    you can copy an individual text apart from an HTML element's text.

            var copyToClipboard = function (text) {
                var $txt = $('