js实现复制功能兼容ios

html:

<div id="copyBT">这是要复制的1内容</div>

<a id="contentas">这是复制按钮</a>

js:

   function copyArticle() {
                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);

  

js实现复制功能兼容ios

上一篇:在Android的c/c++代码中使用LOG


下一篇:关于adb连接手机offline的问题解决