function copyTextToClipboard(text) { var copyFrom = $('<textarea/>'); copyFrom.text(text); $('body').append(copyFrom); copyFrom.select(); document.execCommand('copy'); copyFrom.remove(); }