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?
MyText to copy Copy $(".btnCopy").click(function () { var element = $(this).attr("data"); copyToClipboard($('.' + element)); }); function copyToClipboard(element) { var $temp = $(""); $("body").append($temp); $temp.val($(element).text()).select(); document.execCommand("copy"); $temp.remove(); }