点击复制功能逻辑实现

$(".copyPostScript").click(function(){  //复制按钮
        var copyText = document.getElementById("postScript").innerText;  //要复制的文本信息
        var textareaMiddle = document.getElementById("inputVal");    //存储信息的中间层  ,<textarea id="inputVal"></textarea>
        textareaMiddle.value = copyText;  //暂存
        textareaMiddle.select();  //选择该元素中的文本信息。
        document.execCommand("copy");    // https://developer.mozilla.org/zh-CN/docs/Web/API/Document/execCommand
        //复制成功提示信息。
        $(".hint").css({   
            display:"block",
        });
        _this.timeOut1 = setTimeout(function(){
            $(".hint").css({
                display:"none",
            });
            clearTimeout(_this.timeOut1);
        },2800)
 })
 
 
posted @ 2020-04-28 16:35  Action_swt  阅读(255)  评论(0编辑  收藏  举报