JS浏览器复制

function copyArticle() {
  const range = document.createRange();
  range.selectNode(document.getElementById('content'));
  const selection = window.getSelection();
  if(selection.rangeCount > 0) selection.removeAllRanges();
  selection.addRange(range);
  document.execCommand('copy');
  alert("复制成功!");
  }
  document.getElementById('copyBT').addEventListener('click', copyArticle, false); 

posted on 2019-09-29 11:35  Just丶随心  阅读(412)  评论(0编辑  收藏  举报

导航