<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试实例</title>
<script>
function myFunction(message)
{

    var input = document.createElement("input");
        input.value = message;
        document.body.appendChild(input);
        input.select();
        input.setSelectionRange(0, input.value.length), document.execCommand('Copy');
        document.body.removeChild(input);
        alert("复制成功", "text");
}
</script>
</head>
 
<body>
<div onclick="myFunction('要复制的内容')">点我</div>
</body>
</html>

 

 

参考文章:https://blog.csdn.net/Developersq/article/details/100522751

相关文章:

  • 2021-12-10
  • 2021-12-25
  • 2022-12-23
  • 2021-12-30
  • 2021-07-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-12-03
相关资源
相似解决方案