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

posted @ 2022-01-07 14:14  freedomAndWind  阅读(70)  评论(0编辑  收藏  举报