【js】点击复制

1
2
3
4
5
6
7
8
9
10
11
12
$(".clickCopy").click(function () {
let copyText = $(this).html();
let textarea = document.createElement("textarea");
textarea.style.position = "fixed";
textarea.style.opacity = 0;
textarea.value = copyText;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
console.log("提示复制成功")
});