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?
you can copy an individual text apart from an HTML element's text.
var copyToClipboard = function (text) { var $txt = $(''); $txt.val(text) .css({ width: "1px", height: "1px" }) .appendTo('body'); $txt.select(); if (document.execCommand('copy')) { $txt.remove(); } };