function copy(text){
var input = document.createElement("input");
input.setAttribute("type","text") ;
input.setAttribute("id","testcopy") ;
input.setAttribute("value", text) ;
input.style.width = "10px";
input.style.height = "10px";
input.style.position = "flex";
input.style.top = "0px";
input.style.zIndex = "-10";
document.body.appendChild(input);
var Url = document.getElementById("testcopy");
Url.select();
document.execCommand("Copy");
document.activeElement.blur();
alert('复制成功')
document.getElementById("testcopy").remove()
}
01-05
357
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-06
162
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-05
1190
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)