📌  相关文章
📜  无需输入即可将文本复制到剪贴板 javascript - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:23.535000             🧑  作者: Mango

代码示例3
document.getElementById("cp_btn").addEventListener("click", copy_password);

function copy_password() {
    var copyText = document.getElementById("pwd_spn");
    var textArea = document.createElement("textarea");
    textArea.value = copyText.textContent;
    document.body.appendChild(textArea);
    textArea.select();
    document.execCommand("Copy");
    textArea.remove();
}