js实现复制功能兼容ios

function copyArticle(event) { const range = document.createRange(); range.selectNode(document.getElementById('copyBT')); const selection = window.getSelection(); if(selection.rangeCount > 0) selection.removeAllRanges(); selection.addRange(range); document.execCommand('copy'); alert("复制成功") } document.getElementById('contentas').addEventListener('click', copyArticle, false);
原文地址:https://www.cnblogs.com/zuikeol/p/10684749.html