xym0710

 

function copy() {
    let transfer = document.createElement(\'input\');
    document.body.appendChild(transfer);
    transfer.value = \'这里是想要复制的内容\'; 
    transfer.focus();
    transfer.select();
    if (document.execCommand(\'copy\')) {
        document.execCommand(\'copy\');
    }
    transfer.blur();
    console.log(\'复制成功\');
    document.body.removeChild(transfer);
}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2021-08-15
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-03
  • 2021-09-01
  • 2022-01-10
  • 2022-12-23
  • 2021-11-02
  • 2021-10-18
  • 2022-12-23
相关资源
相似解决方案