【发布时间】:2019-04-27 17:55:21
【问题描述】:
有谁知道如何使用 JavaScript 制作将自己的文本复制到剪贴板的按钮?
我的代码:
function myFunction() {
var copyText = document.getElementByClassName("copy");
copyText.select();
document.execCommand("copy");
}
<button class="copy">Click to copy this text data to clipboard.</button>
<button class="copy">Click to copy this different text data to clipboard.</button>
【问题讨论】:
标签: javascript html button copy