其中br表示复制的内容中加空行
<style>
.copy-content-div {
position: absolute;
z-index: -1;
top: 0;
}
</style>
<div class="copy-content-div" id='copy'>
<div>复制的内容
<br>
</div>
</div>
js中:
copyClick() {//复制按钮的点击事件
var val=document.getElementById("copy");
window.getSelection().selectAllChildren(val);
document.execCommand("Copy");
window.getSelection().removeAllRanges();
},
转载请注明原文地址:https://ipadbbs.8miu.com/read-28449.html