js实现复制(转)

   function copyText() {
        var ctx = document.createElement("input");
        var content = "需要复制的内容";
        ctx.setAttribute("value", content);
        document.body.appendChild(ctx);
        ctx.select();
        document.execCommand("copy");
        document.body.removeChild(ctx);
    }

转至:https://cloud.tencent.com/developer/article/1697532?from=15425

原文地址:https://www.cnblogs.com/linjiangplus/p/15774863.html