function copyTextToClipboard(text) { var textArea = document.createElement("textarea"); textArea.style.background = 'transparent'; textArea.value = text; document.body.appendChild(textArea); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; } catch (err) { console.log('Oops, unable to copy'); } document.body.removeChild(textArea);}
转载于:https://www.cnblogs.com/zinan/p/7145212.html